summaryrefslogtreecommitdiff
path: root/legacy/emotion
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-08-28 09:17:34 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-08-28 09:17:34 +0000
commit97aec1869f7611f16b23f0d66a3539b71ebd9a59 (patch)
treea319b603479428d0992fe755e3b7fe32db2a602a /legacy/emotion
parent635a17d05739a9f478725e8d68dc47dca25dac1a (diff)
emotion: reset VLC pipeline on EOS.
NOTE: I gave up and completely restart the child, seems like the only reliable way to do it. SVN revision: 75769
Diffstat (limited to 'legacy/emotion')
-rw-r--r--legacy/emotion/ChangeLog4
-rw-r--r--legacy/emotion/NEWS1
-rw-r--r--legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c5
-rw-r--r--legacy/emotion/src/lib/emotion_private.h1
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c9
-rw-r--r--legacy/emotion/src/modules/generic/emotion_generic.c71
-rw-r--r--legacy/emotion/src/modules/generic/emotion_generic.h1
7 files changed, 78 insertions, 14 deletions
diff --git a/legacy/emotion/ChangeLog b/legacy/emotion/ChangeLog
index 10d768490a..2aaa70cf90 100644
--- a/legacy/emotion/ChangeLog
+++ b/legacy/emotion/ChangeLog
@@ -41,3 +41,7 @@
412012-08-10 Sohyun Kim 412012-08-10 Sohyun Kim
42 42
43 * Fix priority set/get for gstreamer. 43 * Fix priority set/get for gstreamer.
44
452012-08-28 Cedric Bail
46
47 * Reset VLC pipeline on EOS.
diff --git a/legacy/emotion/NEWS b/legacy/emotion/NEWS
index 8aa8f744e2..07d2b98378 100644
--- a/legacy/emotion/NEWS
+++ b/legacy/emotion/NEWS
@@ -15,6 +15,7 @@ Fixes:
15 - stride of all YUV video 15 - stride of all YUV video
16 - fix race condition in gstreamer render function on shutdown and file set. 16 - fix race condition in gstreamer render function on shutdown and file set.
17 - fix priority set/get for gstreamer. 17 - fix priority set/get for gstreamer.
18 - reset VLC pipeline on EOS.
18 19
19Improvements: 20Improvements:
20 21
diff --git a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c b/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
index 7ec0a6f6c2..583036df6f 100644
--- a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
+++ b/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
@@ -312,7 +312,7 @@ _play(struct _App *app)
312 { 312 {
313 libvlc_time_t new_time = pos * 1000; 313 libvlc_time_t new_time = pos * 1000;
314 libvlc_media_player_set_time(app->mp, new_time); 314 libvlc_media_player_set_time(app->mp, new_time);
315 libvlc_media_player_play(app->mp); 315 libvlc_media_player_play(app->mp);
316 app->playing = 1; 316 app->playing = 1;
317 } 317 }
318} 318}
@@ -395,8 +395,8 @@ _file_set(struct _App *app)
395 fprintf(stderr, "could not open path: \"%s\"\n", app->filename); 395 fprintf(stderr, "could not open path: \"%s\"\n", app->filename);
396 return; 396 return;
397 } 397 }
398 app->mp = libvlc_media_player_new_from_media(app->m);
399 398
399 app->mp = libvlc_media_player_new_from_media(app->m);
400 if (!app->mp) 400 if (!app->mp)
401 { 401 {
402 fprintf(stderr, "could not create new player from media.\n"); 402 fprintf(stderr, "could not create new player from media.\n");
@@ -740,7 +740,6 @@ _process_thread_events(struct _App *app)
740 _send_cmd(app, EM_RESULT_PLAYBACK_STARTED); 740 _send_cmd(app, EM_RESULT_PLAYBACK_STARTED);
741 break; 741 break;
742 case EM_THREAD_PLAYBACK_STOPPED: 742 case EM_THREAD_PLAYBACK_STOPPED:
743 libvlc_media_player_stop(app->mp);
744 app->playing = 0; 743 app->playing = 0;
745 _send_cmd(app, EM_RESULT_PLAYBACK_STOPPED); 744 _send_cmd(app, EM_RESULT_PLAYBACK_STOPPED);
746 break; 745 break;
diff --git a/legacy/emotion/src/lib/emotion_private.h b/legacy/emotion/src/lib/emotion_private.h
index 62801fc7fa..cf24c7543e 100644
--- a/legacy/emotion/src/lib/emotion_private.h
+++ b/legacy/emotion/src/lib/emotion_private.h
@@ -122,6 +122,7 @@ EAPI void _emotion_file_ref_set(Evas_Object *obj, const char *file, int num);
122EAPI void _emotion_spu_button_num_set(Evas_Object *obj, int num); 122EAPI void _emotion_spu_button_num_set(Evas_Object *obj, int num);
123EAPI void _emotion_spu_button_set(Evas_Object *obj, int button); 123EAPI void _emotion_spu_button_set(Evas_Object *obj, int button);
124EAPI void _emotion_seek_done(Evas_Object *obj); 124EAPI void _emotion_seek_done(Evas_Object *obj);
125EAPI void _emotion_image_reset(Evas_Object *obj);
125 126
126EAPI Eina_Bool _emotion_module_register(const char *name, Emotion_Module_Open open, Emotion_Module_Close close); 127EAPI Eina_Bool _emotion_module_register(const char *name, Emotion_Module_Open open, Emotion_Module_Close close);
127EAPI Eina_Bool _emotion_module_unregister(const char *name); 128EAPI Eina_Bool _emotion_module_unregister(const char *name);
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
index 0f6d07de3c..873b587c21 100644
--- a/legacy/emotion/src/lib/emotion_smart.c
+++ b/legacy/emotion/src/lib/emotion_smart.c
@@ -1577,6 +1577,15 @@ _emotion_frame_resize(Evas_Object *obj, int w, int h, double ratio)
1577} 1577}
1578 1578
1579EAPI void 1579EAPI void
1580_emotion_image_reset(Evas_Object *obj)
1581{
1582 Smart_Data *sd;
1583
1584 E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
1585 _emotion_image_data_zero(sd->obj);
1586}
1587
1588EAPI void
1580_emotion_decode_stop(Evas_Object *obj) 1589_emotion_decode_stop(Evas_Object *obj)
1581{ 1590{
1582 Smart_Data *sd; 1591 Smart_Data *sd;
diff --git a/legacy/emotion/src/modules/generic/emotion_generic.c b/legacy/emotion/src/modules/generic/emotion_generic.c
index 69c3b9853c..47e00a7a76 100644
--- a/legacy/emotion/src/modules/generic/emotion_generic.c
+++ b/legacy/emotion/src/modules/generic/emotion_generic.c
@@ -40,6 +40,19 @@ static struct _default_players players[] = {
40 { NULL, NULL } 40 { NULL, NULL }
41}; 41};
42 42
43static Eina_Bool _fork_and_exec(Emotion_Generic_Video *ev);
44static void em_partial_shutdown(Emotion_Generic_Video *ev);
45
46static Eina_Bool
47_player_restart(void *data)
48{
49 Emotion_Generic_Video *ev = data;
50
51 _fork_and_exec(ev);
52 ev->player_restart = NULL;
53 return EINA_FALSE;
54}
55
43static const char * 56static const char *
44_get_player(const char *name) 57_get_player(const char *name)
45{ 58{
@@ -107,18 +120,33 @@ _player_send_cmd(Emotion_Generic_Video *ev, int cmd)
107 ERR("invalid command to player."); 120 ERR("invalid command to player.");
108 return; 121 return;
109 } 122 }
123 if (ev->fd_write == -1)
124 {
125 ERR("you should wait for emotion to be ready to take action.");
126 return ;
127 }
110 if (write(ev->fd_write, &cmd, sizeof(cmd)) < 0) perror("write"); 128 if (write(ev->fd_write, &cmd, sizeof(cmd)) < 0) perror("write");
111} 129}
112 130
113static void 131static void
114_player_send_int(Emotion_Generic_Video *ev, int number) 132_player_send_int(Emotion_Generic_Video *ev, int number)
115{ 133{
134 if (ev->fd_write == -1)
135 {
136 ERR("you should wait for emotion to be ready to take action.");
137 return ;
138 }
116 if (write(ev->fd_write, &number, sizeof(number)) < 0) perror("write"); 139 if (write(ev->fd_write, &number, sizeof(number)) < 0) perror("write");
117} 140}
118 141
119static void 142static void
120_player_send_float(Emotion_Generic_Video *ev, float number) 143_player_send_float(Emotion_Generic_Video *ev, float number)
121{ 144{
145 if (ev->fd_write == -1)
146 {
147 ERR("you should wait for emotion to be ready to take action.");
148 return ;
149 }
122 if (write(ev->fd_write, &number, sizeof(number)) < 0) perror("write"); 150 if (write(ev->fd_write, &number, sizeof(number)) < 0) perror("write");
123} 151}
124 152
@@ -561,7 +589,12 @@ _player_cmd_process(Emotion_Generic_Video *ev)
561 _emotion_playback_started(ev->obj); 589 _emotion_playback_started(ev->obj);
562 break; 590 break;
563 case EM_RESULT_PLAYBACK_STOPPED: 591 case EM_RESULT_PLAYBACK_STOPPED:
592 ev->pos = 0;
564 _emotion_playback_finished(ev->obj); 593 _emotion_playback_finished(ev->obj);
594 _emotion_decode_stop(ev->obj);
595
596 em_partial_shutdown(ev);
597 ev->player_restart = ecore_idler_add(_player_restart, ev);
565 break; 598 break;
566 case EM_RESULT_FRAME_SIZE: 599 case EM_RESULT_FRAME_SIZE:
567 _player_frame_resize(ev); 600 _player_frame_resize(ev);
@@ -944,7 +977,7 @@ _player_exec(Emotion_Generic_Video *ev)
944} 977}
945 978
946static Eina_Bool 979static Eina_Bool
947_fork_and_exec(Evas_Object *obj __UNUSED__, Emotion_Generic_Video *ev) 980_fork_and_exec(Emotion_Generic_Video *ev)
948{ 981{
949 char shmname[256]; 982 char shmname[256];
950 struct timeval tv; 983 struct timeval tv;
@@ -962,7 +995,6 @@ _fork_and_exec(Evas_Object *obj __UNUSED__, Emotion_Generic_Video *ev)
962 ev->player_data = ecore_event_handler_add( 995 ev->player_data = ecore_event_handler_add(
963 ECORE_EXE_EVENT_DATA, _player_data_cb, ev); 996 ECORE_EXE_EVENT_DATA, _player_data_cb, ev);
964 997
965
966 if (!_player_exec(ev)) 998 if (!_player_exec(ev))
967 { 999 {
968 ERR("could not start player."); 1000 ERR("could not start player.");
@@ -998,15 +1030,13 @@ em_init(Evas_Object *obj, void **emotion_video, Emotion_Module_Options *opt)
998 ev->cmdline = eina_stringshare_add(player); 1030 ev->cmdline = eina_stringshare_add(player);
999 *emotion_video = ev; 1031 *emotion_video = ev;
1000 1032
1001 return _fork_and_exec(obj, ev); 1033 return _fork_and_exec(ev);
1002} 1034}
1003 1035
1004static int 1036static void
1005em_shutdown(void *data) 1037em_partial_shutdown(Emotion_Generic_Video *ev)
1006{ 1038{
1007 Emotion_Generic_Video *ev = data; 1039 _emotion_image_reset(ev->obj);
1008
1009 if (!ev) return 0;
1010 1040
1011 if (ev->player.exe) 1041 if (ev->player.exe)
1012 { 1042 {
@@ -1017,20 +1047,39 @@ em_shutdown(void *data)
1017 1047
1018 if (ev->shared) 1048 if (ev->shared)
1019 munmap(ev->shared, ev->shared->size); 1049 munmap(ev->shared, ev->shared->size);
1050 ev->shared = NULL;
1020 1051
1021 if (ev->fd_read >= 0) 1052 if (ev->fd_read >= 0)
1022 close(ev->fd_read); 1053 close(ev->fd_read);
1054 ev->fd_read = -1;
1023 if (ev->fd_write >= 0) 1055 if (ev->fd_write >= 0)
1024 close(ev->fd_write); 1056 close(ev->fd_write);
1057 ev->fd_write = -1;
1025 if (ev->fd_handler) 1058 if (ev->fd_handler)
1026 ecore_main_fd_handler_del(ev->fd_handler); 1059 ecore_main_fd_handler_del(ev->fd_handler);
1060 ev->fd_handler = NULL;
1061
1062 if (ev->player_add) ecore_event_handler_del(ev->player_add);
1063 ev->player_add = NULL;
1064 if (ev->player_data) ecore_event_handler_del(ev->player_data);
1065 ev->player_data = NULL;
1066 if (ev->player_del) ecore_event_handler_del(ev->player_del);
1067 ev->player_del = NULL;
1068 if (ev->player_restart) ecore_idler_del(ev->player_restart);
1069 ev->player_restart = NULL;
1070}
1071
1072static int
1073em_shutdown(void *data)
1074{
1075 Emotion_Generic_Video *ev = data;
1076
1077 if (!ev) return 0;
1027 1078
1028 eina_stringshare_del(ev->cmdline); 1079 eina_stringshare_del(ev->cmdline);
1029 eina_stringshare_del(ev->shmname); 1080 eina_stringshare_del(ev->shmname);
1030 1081
1031 ecore_event_handler_del(ev->player_add); 1082 em_partial_shutdown(ev);
1032 ecore_event_handler_del(ev->player_data);
1033 ecore_event_handler_del(ev->player_del);
1034 1083
1035 return 1; 1084 return 1;
1036} 1085}
diff --git a/legacy/emotion/src/modules/generic/emotion_generic.h b/legacy/emotion/src/modules/generic/emotion_generic.h
index 50dd8e4f88..ed3bdb042e 100644
--- a/legacy/emotion/src/modules/generic/emotion_generic.h
+++ b/legacy/emotion/src/modules/generic/emotion_generic.h
@@ -67,6 +67,7 @@ struct _Emotion_Generic_Video
67 Emotion_Generic_Player player; 67 Emotion_Generic_Player player;
68 Emotion_Generic_Cmd_Buffer cmd; 68 Emotion_Generic_Cmd_Buffer cmd;
69 Ecore_Event_Handler *player_add, *player_del, *player_data; 69 Ecore_Event_Handler *player_add, *player_del, *player_data;
70 Ecore_Idler *player_restart;
70 int drop; 71 int drop;
71 int fd_read, fd_write; 72 int fd_read, fd_write;
72 Ecore_Fd_Handler *fd_handler; 73 Ecore_Fd_Handler *fd_handler;