summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2008-09-26 23:17:57 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2008-09-26 23:17:57 +0000
commitaa3aac7dbfd67d5184d41fa73b581df337bcc7ef (patch)
treec7a2a65a01bb4fdb05b6c0d2b4e4e9a173baa716
parent2acd11a39ec554ef390bb840175a11e108732379 (diff)
Fix position reporting.
Always call pos_get() and also fix these on xine and gstreamer, we should query the current position and do not trust cached value. For instance, when no video is present, no handoff/frame-decoded is called so no cache is updated. SVN revision: 36271
-rw-r--r--legacy/emotion/src/bin/emotion_test_main.c54
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c2
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c56
-rw-r--r--legacy/emotion/src/modules/xine/emotion_xine.c2
4 files changed, 84 insertions, 30 deletions
diff --git a/legacy/emotion/src/bin/emotion_test_main.c b/legacy/emotion/src/bin/emotion_test_main.c
index fbf2a0442f..10be617a15 100644
--- a/legacy/emotion/src/bin/emotion_test_main.c
+++ b/legacy/emotion/src/bin/emotion_test_main.c
@@ -467,18 +467,17 @@ video_obj_move_cb(void *data, Evas *ev, Evas_Object *obj, void *event_info)
467} 467}
468 468
469static void 469static void
470video_obj_frame_decode_cb(void *data, Evas_Object *obj, void *event_info) 470video_obj_time_changed(Evas_Object *obj, Evas_Object *edje)
471{ 471{
472 Evas_Object *oe; 472 double pos, len, scale;
473 double pos, len;
474 char buf[256]; 473 char buf[256];
475 int ph, pm, ps, pf, lh, lm, ls; 474 int ph, pm, ps, pf, lh, lm, ls;
476 475
477 oe = data;
478 pos = emotion_object_position_get(obj); 476 pos = emotion_object_position_get(obj);
479 len = emotion_object_play_length_get(obj); 477 len = emotion_object_play_length_get(obj);
480// printf("%3.3f, %3.3f\n", pos, len); 478// printf("%3.3f, %3.3f\n", pos, len);
481 edje_object_part_drag_value_set(oe, "video_progress", pos / len, 0.0); 479 scale = (len > 0.0) ? pos / len : 0.0;
480 edje_object_part_drag_value_set(edje, "video_progress", scale, 0.0);
482 lh = len / 3600; 481 lh = len / 3600;
483 lm = len / 60 - (lh * 60); 482 lm = len / 60 - (lh * 60);
484 ls = len - (lm * 60); 483 ls = len - (lm * 60);
@@ -488,7 +487,13 @@ video_obj_frame_decode_cb(void *data, Evas_Object *obj, void *event_info)
488 pf = pos * 100 - (ps * 100) - (pm * 60 * 100) - (ph * 60 * 60 * 100); 487 pf = pos * 100 - (ps * 100) - (pm * 60 * 100) - (ph * 60 * 60 * 100);
489 snprintf(buf, sizeof(buf), "%i:%02i:%02i.%02i / %i:%02i:%02i", 488 snprintf(buf, sizeof(buf), "%i:%02i:%02i.%02i / %i:%02i:%02i",
490 ph, pm, ps, pf, lh, lm, ls); 489 ph, pm, ps, pf, lh, lm, ls);
491 edje_object_part_text_set(oe, "video_progress_txt", buf); 490 edje_object_part_text_set(edje, "video_progress_txt", buf);
491}
492
493static void
494video_obj_frame_decode_cb(void *data, Evas_Object *obj, void *event_info)
495{
496 video_obj_time_changed(obj, data);
492 497
493 if (0) 498 if (0)
494 { 499 {
@@ -524,25 +529,13 @@ video_obj_frame_resize_cb(void *data, Evas_Object *obj, void *event_info)
524static void 529static void
525video_obj_length_change_cb(void *data, Evas_Object *obj, void *event_info) 530video_obj_length_change_cb(void *data, Evas_Object *obj, void *event_info)
526{ 531{
527 Evas_Object *oe; 532 video_obj_time_changed(obj, data);
528 double pos, len; 533}
529 char buf[256];
530 int ph, pm, ps, pf, lh, lm, ls;
531 534
532 oe = data; 535static void
533 pos = emotion_object_position_get(obj); 536video_obj_position_update_cb(void *data, Evas_Object *obj, void *event_info)
534 len = emotion_object_play_length_get(obj); 537{
535 edje_object_part_drag_value_set(oe, "video_progress", pos / len, 0.0); 538 video_obj_time_changed(obj, data);
536 lh = len / 3600;
537 lm = len / 60 - (lh * 60);
538 ls = len - (lm * 60);
539 ph = pos / 3600;
540 pm = pos / 60 - (ph * 60);
541 ps = pos - (pm * 60);
542 pf = pos * 100 - (ps * 100) - (pm * 60 * 100) - (ph * 60 * 60 * 100);
543 snprintf(buf, sizeof(buf), "%i:%02i:%02i.%02i / %i:%02i:%02i",
544 ph, pm, ps, pf, lh, lm, ls);
545 edje_object_part_text_set(oe, "video_progress_txt", buf);
546} 539}
547 540
548static void 541static void
@@ -801,6 +794,7 @@ init_video_object(char *module_filename, char *filename)
801 evas_object_smart_callback_add(o, "frame_decode", video_obj_frame_decode_cb, oe); 794 evas_object_smart_callback_add(o, "frame_decode", video_obj_frame_decode_cb, oe);
802 evas_object_smart_callback_add(o, "frame_resize", video_obj_frame_resize_cb, oe); 795 evas_object_smart_callback_add(o, "frame_resize", video_obj_frame_resize_cb, oe);
803 evas_object_smart_callback_add(o, "length_change", video_obj_length_change_cb, oe); 796 evas_object_smart_callback_add(o, "length_change", video_obj_length_change_cb, oe);
797 evas_object_smart_callback_add(o, "position_update", video_obj_position_update_cb, oe);
804 798
805 evas_object_smart_callback_add(o, "decode_stop", video_obj_stopped_cb, oe); 799 evas_object_smart_callback_add(o, "decode_stop", video_obj_stopped_cb, oe);
806 evas_object_smart_callback_add(o, "channels_change", video_obj_channels_cb, oe); 800 evas_object_smart_callback_add(o, "channels_change", video_obj_channels_cb, oe);
@@ -848,6 +842,17 @@ enter_idle(void *data)
848 return 1; 842 return 1;
849} 843}
850 844
845static int
846check_positions(void *data)
847{
848 const Evas_List *lst;
849
850 for (lst = video_objs; lst != NULL; lst = lst->next)
851 video_obj_time_changed(lst->data, evas_object_smart_parent_get(lst->data));
852
853 return !!video_objs;
854}
855
851int 856int
852main(int argc, char **argv) 857main(int argc, char **argv)
853{ 858{
@@ -902,6 +907,7 @@ main(int argc, char **argv)
902 } 907 }
903 908
904 ecore_idle_enterer_add(enter_idle, NULL); 909 ecore_idle_enterer_add(enter_idle, NULL);
910 ecore_animator_add(check_positions, NULL);
905 911
906 ecore_main_loop_begin(); 912 ecore_main_loop_begin();
907 main_stop(); 913 main_stop();
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
index f77ce76fb5..f932962e17 100644
--- a/legacy/emotion/src/lib/emotion_smart.c
+++ b/legacy/emotion/src/lib/emotion_smart.c
@@ -319,6 +319,8 @@ emotion_object_position_get(Evas_Object *obj)
319 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0); 319 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0.0);
320 if (!sd->module) return 0.0; 320 if (!sd->module) return 0.0;
321 if (!sd->video) return 0.0; 321 if (!sd->video) return 0.0;
322 if (!sd->module->pos_get) return 0.0;
323 sd->pos = sd->module->pos_get(sd->video);
322 return sd->pos; 324 return sd->pos;
323} 325}
324 326
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
index 2ada21518a..01d989443f 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
@@ -590,13 +590,42 @@ static double
590em_len_get(void *video) 590em_len_get(void *video)
591{ 591{
592 Emotion_Gstreamer_Video *ev; 592 Emotion_Gstreamer_Video *ev;
593 Emotion_Video_Sink *vsink; 593 Emotion_Video_Sink *vsink;
594 Emotion_Audio_Sink *asink;
595 GstFormat fmt;
596 gint64 val;
597 gboolean ret;
598
599 ev = video;
600 fmt = GST_FORMAT_TIME;
601 ret = gst_element_query_duration(ev->pipeline, &fmt, &val);
602 if (!ret)
603 goto fallback;
604
605 if (fmt != GST_FORMAT_TIME)
606 {
607 fprintf(stderr, "requrested duration in time, but got %s instead.",
608 gst_format_get_name(fmt));
609 goto fallback;
610 }
594 611
595 ev = (Emotion_Gstreamer_Video *)video; 612 if (val <= 0.0)
613 goto fallback;
596 614
597 vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); 615 return val / 1000000000.0;
598 if (vsink) 616
599 return (double)vsink->length_time; 617 fallback:
618 fputs("Gstreamer reported no length, try existing sinks...\n", stderr);
619
620 ecore_list_first_goto(ev->audio_sinks);
621 while ((asink = ecore_list_next(ev->audio_sinks)) != NULL)
622 if (asink->length_time >= 0)
623 return asink->length_time;
624
625 ecore_list_first_goto(ev->video_sinks);
626 while ((vsink = ecore_list_next(ev->video_sinks)) != NULL)
627 if (vsink->length_time >= 0)
628 return vsink->length_time;
600 629
601 return 0.0; 630 return 0.0;
602} 631}
@@ -650,9 +679,24 @@ static double
650em_pos_get(void *video) 679em_pos_get(void *video)
651{ 680{
652 Emotion_Gstreamer_Video *ev; 681 Emotion_Gstreamer_Video *ev;
682 GstFormat fmt;
683 gint64 val;
684 gboolean ret;
653 685
654 ev = (Emotion_Gstreamer_Video *)video; 686 ev = video;
687 fmt = GST_FORMAT_TIME;
688 ret = gst_element_query_position(ev->pipeline, &fmt, &val);
689 if (!ret)
690 return ev->position;
691
692 if (fmt != GST_FORMAT_TIME)
693 {
694 fprintf(stderr, "requrested position in time, but got %s instead.",
695 gst_format_get_name(fmt));
696 return ev->position;
697 }
655 698
699 ev->position = val / 1000000000.0;
656 return ev->position; 700 return ev->position;
657} 701}
658 702
diff --git a/legacy/emotion/src/modules/xine/emotion_xine.c b/legacy/emotion/src/modules/xine/emotion_xine.c
index 9f902757b0..e1e457689f 100644
--- a/legacy/emotion/src/modules/xine/emotion_xine.c
+++ b/legacy/emotion/src/modules/xine/emotion_xine.c
@@ -551,6 +551,7 @@ em_pos_get(void *ef)
551 Emotion_Xine_Video *ev; 551 Emotion_Xine_Video *ev;
552 552
553 ev = (Emotion_Xine_Video *)ef; 553 ev = (Emotion_Xine_Video *)ef;
554 _em_get_pos_len(ev);
554 return ev->pos; 555 return ev->pos;
555} 556}
556 557
@@ -1456,6 +1457,7 @@ _em_get_pos_len_th(void *par)
1456static void 1457static void
1457_em_get_pos_len(Emotion_Xine_Video *ev) 1458_em_get_pos_len(Emotion_Xine_Video *ev)
1458{ 1459{
1460 if (!ev->play_ok) return;
1459 if (ev->get_poslen) return; 1461 if (ev->get_poslen) return;
1460 ev->get_poslen = 1; 1462 ev->get_poslen = 1;
1461 pthread_mutex_lock(&(ev->get_pos_len_mutex)); 1463 pthread_mutex_lock(&(ev->get_pos_len_mutex));