Enlightenment CVS committal
Author : raster
Project : e17
Module : apps/elation
Dir : e17/apps/elation/src/modules
Modified Files:
elation_cd.c elation_disk.c
Log Message:
handle cd's better
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/elation/src/modules/elation_cd.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- elation_cd.c 24 Jul 2004 05:19:33 -0000 1.1
+++ elation_cd.c 24 Jul 2004 07:19:47 -0000 1.2
@@ -16,14 +16,10 @@
struct _Elation_Module_Private
{
- Evas_Object *background1;
- Evas_Object *background2;
+ char *device;
+ int track;
+ int track_num;
Evas_Object *video;
-
- double media_fade_in_start;
- Ecore_Timer *media_fade_in_timer;
-
- unsigned char menu_visible : 1;
};
static void shutdown(Elation_Module *em);
@@ -35,15 +31,11 @@
static void action(Elation_Module *em, int action);
static void frame_decode_cb(void *data, Evas_Object *obj, void *event_info);
-static void frame_resize_cb(void *data, Evas_Object *obj, void *event_info);
static void length_change_cb(void *data, Evas_Object *obj, void *event_info);
static void decode_stop_cb(void *data, Evas_Object *obj, void *event_info);
-static void button_num_change_cb(void *data, Evas_Object *obj, void *event_info);
static void title_change_cb(void *data, Evas_Object *obj, void *event_info);
static void progress_change_cb(void *data, Evas_Object *obj, void *event_info);
static void channels_change_cb(void *data, Evas_Object *obj, void *event_info);
-static void ref_change_cb(void *data, Evas_Object *obj, void *event_info);
-static void button_change_cb(void *data, Evas_Object *obj, void *event_info);
static void key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
static int media_play_timer_cb(void *data);
static int media_fade_in_timer_cb(void *data);
@@ -65,33 +57,64 @@
em->unfocus = unfocus;
em->action = action;
- pr->background1 = evas_object_rectangle_add(em->info->evas);
- evas_object_color_set(pr->background1, 0, 0, 0, 255);
- pr->background2 = evas_object_rectangle_add(em->info->evas);
- evas_object_color_set(pr->background2, 0, 0, 0, 255);
+ pr->device = strdup("/dev/cdrom");
pr->video = emotion_object_add(em->info->evas);
evas_object_event_callback_add(pr->video, EVAS_CALLBACK_KEY_DOWN, key_down_cb, em);
evas_object_smart_callback_add(pr->video, "frame_decode", frame_decode_cb, em);
- evas_object_smart_callback_add(pr->video, "frame_resize", frame_resize_cb, em);
evas_object_smart_callback_add(pr->video, "length_change",length_change_cb, em);
evas_object_smart_callback_add(pr->video, "decode_stop", decode_stop_cb, em);
- evas_object_smart_callback_add(pr->video, "button_num_change",
button_num_change_cb, em);
evas_object_smart_callback_add(pr->video, "title_change", title_change_cb, em);
evas_object_smart_callback_add(pr->video, "progress_change", progress_change_cb,
em);
evas_object_smart_callback_add(pr->video, "channels_change", channels_change_cb,
em);
- evas_object_smart_callback_add(pr->video, "ref_change", ref_change_cb, em);
- evas_object_smart_callback_add(pr->video, "button_change", button_change_cb, em);
-
- emotion_object_smooth_scale_set(pr->video, 1);
-
- emotion_object_file_set(pr->video, "cdda:/1");
- emotion_object_play_set(pr->video, 1);
-
- pr->media_fade_in_timer = ecore_timer_add(1.0 / 30.0, media_fade_in_timer_cb, em);
- pr->media_fade_in_start = ecore_time_get();
+
+ {
+ int fd;
+
+ fd = open(pr->device, O_RDONLY | O_NONBLOCK);
+ if (fd >= 0)
+ {
+ int ret;
+ struct cdrom_tochdr hd;
+
+ ret = ioctl(fd, CDROMREADTOCHDR, &hd);
+ if (ret == 0)
+ {
+ int i;
+
+ pr->track_num = hd.cdth_trk1;
+ printf("hd->cdth_trk0 = %i, hd->cdth_trk1 = %i\n",
+ (int)hd.cdth_trk0, (int)hd.cdth_trk1);
+ for (i = 1; i <= hd.cdth_trk1; i++)
+ {
+ struct cdrom_tocentry ent;
+
+ ent.cdte_track = i;
+ ent.cdte_format = CDROM_MSF;
+ ret = ioctl(fd, CDROMREADTOCENTRY, &ent);
+ if (ret == 0)
+ {
+ int sec;
+
+ sec = ent.cdte_addr.msf.minute * 60;
+ sec += ent.cdte_addr.msf.second;
+ printf("TRACK %i = %i sec [f: %i]\n", i, sec,
+ (int)ent.cdte_addr.msf.frame);
+ }
+ }
+ }
+ close(fd);
+ }
+ }
+ {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "cdda:/%i", pr->track + 1);
+ emotion_object_file_set(pr->video, buf);
+ emotion_object_play_set(pr->video, 1);
+ }
return pr;
}
@@ -102,10 +125,7 @@
Elation_Module_Private *pr;
pr = em->data;
- evas_object_del(pr->background1);
- evas_object_del(pr->background2);
evas_object_del(pr->video);
- if (pr->media_fade_in_timer) ecore_timer_del(pr->media_fade_in_timer);
free(pr);
}
@@ -113,67 +133,13 @@
resize(Elation_Module *em)
{
Elation_Module_Private *pr;
- Evas_Coord x, y, w, h, ww, hh;
- double ratio;
- int vw, vh;
+ Evas_Coord w, h;
pr = em->data;
evas_output_viewport_get(em->info->evas, NULL, NULL, &w, &h);
- ww = w;
- hh = h;
-
- emotion_object_size_get(pr->video, &vw, &vh);
- ratio = emotion_object_ratio_get(pr->video);
- if (ratio > 0.0)
- {
- x = 0;
- y = (h - (w / ratio)) / 2;
- if (y < 0)
- {
- y = 0;
- x = (w - (h * ratio)) / 2;
- w = h * ratio;
- }
- else
- h = w / ratio;
- evas_object_move(pr->video, x, y);
- evas_object_resize(pr->video, w, h);
- }
- else
- {
- if (vh > 1)
- {
- ratio = (double)vw / (double)vh;
- x = 0;
- y = (h - (w / ratio)) / 2;
- if (y < 0)
- {
- y = 0;
- x = (w - (h * ratio)) / 2;
- w = h * ratio;
- }
- else
- h = w / ratio;
- }
- evas_object_move(pr->video, 0, 0);
- evas_object_resize(pr->video, w, h);
- }
-
- if (w == ww)
- {
- evas_object_move(pr->background1, 0, 0);
- evas_object_resize(pr->background1, ww, y);
- evas_object_move(pr->background2, 0, y + h);
- evas_object_resize(pr->background2, ww, hh - h - y);
- }
- else
- {
- evas_object_move(pr->background1, 0, 0);
- evas_object_resize(pr->background1, x, hh);
- evas_object_move(pr->background2, x + w, 0);
- evas_object_resize(pr->background2, ww - w - x, hh);
- }
+ evas_object_move(pr->video, 0, 0);
+ evas_object_resize(pr->video, w, h);
}
static void
@@ -182,9 +148,6 @@
Elation_Module_Private *pr;
pr = em->data;
- evas_object_show(pr->background1);
- evas_object_show(pr->background2);
- evas_object_show(pr->video);
}
static void
@@ -193,9 +156,6 @@
Elation_Module_Private *pr;
pr = em->data;
- evas_object_hide(pr->background1);
- evas_object_hide(pr->background2);
- evas_object_hide(pr->video);
}
static void
@@ -225,56 +185,43 @@
switch (action)
{
case ELATION_ACT_NEXT:
- if (pr->menu_visible)
+ pr->track++;
+ if (pr->track >= pr->track_num) pr->track = 0;
+ printf("next to %i\n", pr->track);
{
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "cdda:/%i", pr->track + 1);
+ emotion_object_file_set(pr->video, buf);
+ emotion_object_play_set(pr->video, 1);
}
- else
- emotion_object_event_simple_send(pr->video, EMOTION_EVENT_NEXT);
break;
case ELATION_ACT_PREV:
- if (pr->menu_visible)
+ pr->track--;
+ if (pr->track < 0) pr->track = pr->track_num - 1;
{
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "cdda:/%i", pr->track + 1);
+ emotion_object_file_set(pr->video, buf);
+ emotion_object_play_set(pr->video, 1);
}
- else
- emotion_object_event_simple_send(pr->video, EMOTION_EVENT_PREV);
break;
case ELATION_ACT_SELECT:
- if (pr->menu_visible)
- emotion_object_event_simple_send(pr->video, EMOTION_EVENT_SELECT);
+ if (emotion_object_play_get(pr->video))
+ emotion_object_play_set(pr->video, 0);
else
- {
- if (emotion_object_play_get(pr->video))
- emotion_object_play_set(pr->video, 0);
- else
- emotion_object_play_set(pr->video, 1);
- }
+ emotion_object_play_set(pr->video, 1);
break;
case ELATION_ACT_EXIT:
- {
- em->info->func.action_broadcast(ELATION_ACT_DISK_EJECT);
- em->shutdown(em);
- }
+ em->info->func.action_broadcast(ELATION_ACT_DISK_EJECT);
+ em->shutdown(em);
break;
case ELATION_ACT_UP:
- if (pr->menu_visible)
- emotion_object_event_simple_send(pr->video, EMOTION_EVENT_UP);
- else
- {
- // FIXME: bring up config menu
- }
break;
case ELATION_ACT_DOWN:
- if (pr->menu_visible)
- emotion_object_event_simple_send(pr->video, EMOTION_EVENT_DOWN);
- else
- {
- // FIXME: bring up config menu
- }
break;
case ELATION_ACT_LEFT:
- if (pr->menu_visible)
- emotion_object_event_simple_send(pr->video, EMOTION_EVENT_LEFT);
- else
{
double pos;
@@ -283,9 +230,6 @@
}
break;
case ELATION_ACT_RIGHT:
- if (pr->menu_visible)
- emotion_object_event_simple_send(pr->video, EMOTION_EVENT_RIGHT);
- else
{
double pos;
@@ -294,62 +238,23 @@
}
break;
case ELATION_ACT_MENU:
- if (pr->menu_visible)
- {
- // FIXME: bring up config menu
- }
- else
- emotion_object_event_simple_send(pr->video, EMOTION_EVENT_MENU1);
break;
case ELATION_ACT_INFO:
- if (pr->menu_visible)
- {
- // FIXME: bring up config menu
- }
- else
- {
- }
break;
case ELATION_ACT_INPUT:
- if (pr->menu_visible)
- {
- // FIXME: bring up config menu
- }
- else
- {
- }
break;
case ELATION_ACT_PLAY:
- if (pr->menu_visible)
- {
- emotion_object_event_simple_send(pr->video, EMOTION_EVENT_NEXT);
- }
- else
- {
- emotion_object_play_set(pr->video, 1);
- }
+ emotion_object_play_set(pr->video, 1);
break;
case ELATION_ACT_PAUSE:
- if (pr->menu_visible)
- {
- }
+ if (emotion_object_play_get(pr->video))
+ emotion_object_play_set(pr->video, 0);
else
- {
- if (emotion_object_play_get(pr->video))
- emotion_object_play_set(pr->video, 0);
- else
- emotion_object_play_set(pr->video, 1);
- }
+ emotion_object_play_set(pr->video, 1);
break;
case ELATION_ACT_STOP:
- if (pr->menu_visible)
- {
- }
- else
- {
- emotion_object_play_set(pr->video, 0);
- emotion_object_position_set(pr->video, 0.0);
- }
+ emotion_object_play_set(pr->video, 0);
+ emotion_object_position_set(pr->video, 0.0);
break;
default:
break;
@@ -367,15 +272,7 @@
em = data;
pos = emotion_object_position_get(obj);
len = emotion_object_play_length_get(obj);
-}
-
-static void
-frame_resize_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Elation_Module *em;
-
- em = data;
- em->resize(em);
+// printf("EL decode %3.3f / %3.3f\n", pos, len);
}
static void
@@ -387,6 +284,7 @@
em = data;
pos = emotion_object_position_get(obj);
len = emotion_object_play_length_get(obj);
+ printf("EL length change %3.3f / %3.3f\n", pos, len);
}
static void
@@ -397,22 +295,18 @@
em = data;
pr = em->data;
+ printf("EL video stop\n");
// emotion_object_position_set(pr->video, 0.0);
// emotion_object_play_set(pr->video, 1);
-}
-
-static void
-button_num_change_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Elation_Module *em;
- Elation_Module_Private *pr;
-
- em = data;
- pr = em->data;
- if (emotion_object_spu_button_count_get(pr->video) > 0)
- pr->menu_visible = 1;
- else
- pr->menu_visible = 0;
+ pr->track++;
+ if (pr->track >= pr->track_num) pr->track = 0;
+ {
+ char buf[256];
+
+ snprintf(buf, sizeof(buf), "cdda:/%i", pr->track + 1);
+ emotion_object_file_set(pr->video, buf);
+ emotion_object_play_set(pr->video, 1);
+ }
}
static void
@@ -454,31 +348,6 @@
}
static void
-ref_change_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Elation_Module *em;
- Elation_Module_Private *pr;
-
- em = data;
- pr = em->data;
- printf("EL video ref to: \"%s\" %i\n",
- emotion_object_ref_file_get(pr->video),
- emotion_object_ref_num_get(pr->video));
-}
-
-static void
-button_change_cb(void *data, Evas_Object *obj, void *event_info)
-{
- Elation_Module *em;
- Elation_Module_Private *pr;
-
- em = data;
- pr = em->data;
- printf("EL video selected spu button: %i\n",
- emotion_object_spu_button_get(pr->video));
-}
-
-static void
key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Event_Key_Down *ev;
@@ -510,24 +379,3 @@
else if (!strcmp(ev->keyname, "k")) action = ELATION_ACT_SKIP;
em->action(em, action);
}
-
-static int
-media_fade_in_timer_cb(void *data)
-{
- Elation_Module *em;
- Elation_Module_Private *pr;
- int a;
- double t;
-
- em = data;
- pr = em->data;
- t = ecore_time_get() - pr->media_fade_in_start;
- a = (t * 255) / 10.0;
- if (a > 255) a = 255;
- evas_object_color_set(pr->background1, 0, 0, 0, a);
- evas_object_color_set(pr->background2, 0, 0, 0, a);
- evas_object_color_set(pr->video, 255, 255, 255, a);
- if (a < 255) return 1;
- pr->media_fade_in_timer = NULL;
- return 0;
-}
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/elation/src/modules/elation_disk.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- elation_disk.c 24 Jul 2004 05:19:33 -0000 1.2
+++ elation_disk.c 24 Jul 2004 07:19:48 -0000 1.3
@@ -83,7 +83,7 @@
em->unfocus = unfocus;
em->action = action;
- pr->device = strdup("/dev/dvd");
+ pr->device = strdup("/dev/cdrom");
{
int fds_in[2], fds_out[2];
pid_t pid;
@@ -263,7 +263,7 @@
int i;
printf("eject disk!\n");
- for (i = 0; i < 5; i++)
+ for (i = 0; i < 10; i++)
{
if (ioctl(fd, CDROMEJECT, 0) == 0) break;
perror("ioctl");
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs