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
This commit is contained in:
Cedric BAIL 2012-08-28 09:17:34 +00:00
parent 635a17d057
commit 97aec1869f
7 changed files with 78 additions and 14 deletions

View File

@ -41,3 +41,7 @@
2012-08-10 Sohyun Kim
* Fix priority set/get for gstreamer.
2012-08-28 Cedric Bail
* Reset VLC pipeline on EOS.

View File

@ -15,6 +15,7 @@ Fixes:
- stride of all YUV video
- fix race condition in gstreamer render function on shutdown and file set.
- fix priority set/get for gstreamer.
- reset VLC pipeline on EOS.
Improvements:

View File

@ -312,7 +312,7 @@ _play(struct _App *app)
{
libvlc_time_t new_time = pos * 1000;
libvlc_media_player_set_time(app->mp, new_time);
libvlc_media_player_play(app->mp);
libvlc_media_player_play(app->mp);
app->playing = 1;
}
}
@ -395,8 +395,8 @@ _file_set(struct _App *app)
fprintf(stderr, "could not open path: \"%s\"\n", app->filename);
return;
}
app->mp = libvlc_media_player_new_from_media(app->m);
app->mp = libvlc_media_player_new_from_media(app->m);
if (!app->mp)
{
fprintf(stderr, "could not create new player from media.\n");
@ -740,7 +740,6 @@ _process_thread_events(struct _App *app)
_send_cmd(app, EM_RESULT_PLAYBACK_STARTED);
break;
case EM_THREAD_PLAYBACK_STOPPED:
libvlc_media_player_stop(app->mp);
app->playing = 0;
_send_cmd(app, EM_RESULT_PLAYBACK_STOPPED);
break;

View File

@ -122,6 +122,7 @@ EAPI void _emotion_file_ref_set(Evas_Object *obj, const char *file, int num);
EAPI void _emotion_spu_button_num_set(Evas_Object *obj, int num);
EAPI void _emotion_spu_button_set(Evas_Object *obj, int button);
EAPI void _emotion_seek_done(Evas_Object *obj);
EAPI void _emotion_image_reset(Evas_Object *obj);
EAPI Eina_Bool _emotion_module_register(const char *name, Emotion_Module_Open open, Emotion_Module_Close close);
EAPI Eina_Bool _emotion_module_unregister(const char *name);

View File

@ -1576,6 +1576,15 @@ _emotion_frame_resize(Evas_Object *obj, int w, int h, double ratio)
}
}
EAPI void
_emotion_image_reset(Evas_Object *obj)
{
Smart_Data *sd;
E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME);
_emotion_image_data_zero(sd->obj);
}
EAPI void
_emotion_decode_stop(Evas_Object *obj)
{

View File

@ -40,6 +40,19 @@ static struct _default_players players[] = {
{ NULL, NULL }
};
static Eina_Bool _fork_and_exec(Emotion_Generic_Video *ev);
static void em_partial_shutdown(Emotion_Generic_Video *ev);
static Eina_Bool
_player_restart(void *data)
{
Emotion_Generic_Video *ev = data;
_fork_and_exec(ev);
ev->player_restart = NULL;
return EINA_FALSE;
}
static const char *
_get_player(const char *name)
{
@ -107,18 +120,33 @@ _player_send_cmd(Emotion_Generic_Video *ev, int cmd)
ERR("invalid command to player.");
return;
}
if (ev->fd_write == -1)
{
ERR("you should wait for emotion to be ready to take action.");
return ;
}
if (write(ev->fd_write, &cmd, sizeof(cmd)) < 0) perror("write");
}
static void
_player_send_int(Emotion_Generic_Video *ev, int number)
{
if (ev->fd_write == -1)
{
ERR("you should wait for emotion to be ready to take action.");
return ;
}
if (write(ev->fd_write, &number, sizeof(number)) < 0) perror("write");
}
static void
_player_send_float(Emotion_Generic_Video *ev, float number)
{
if (ev->fd_write == -1)
{
ERR("you should wait for emotion to be ready to take action.");
return ;
}
if (write(ev->fd_write, &number, sizeof(number)) < 0) perror("write");
}
@ -561,7 +589,12 @@ _player_cmd_process(Emotion_Generic_Video *ev)
_emotion_playback_started(ev->obj);
break;
case EM_RESULT_PLAYBACK_STOPPED:
ev->pos = 0;
_emotion_playback_finished(ev->obj);
_emotion_decode_stop(ev->obj);
em_partial_shutdown(ev);
ev->player_restart = ecore_idler_add(_player_restart, ev);
break;
case EM_RESULT_FRAME_SIZE:
_player_frame_resize(ev);
@ -944,7 +977,7 @@ _player_exec(Emotion_Generic_Video *ev)
}
static Eina_Bool
_fork_and_exec(Evas_Object *obj __UNUSED__, Emotion_Generic_Video *ev)
_fork_and_exec(Emotion_Generic_Video *ev)
{
char shmname[256];
struct timeval tv;
@ -962,7 +995,6 @@ _fork_and_exec(Evas_Object *obj __UNUSED__, Emotion_Generic_Video *ev)
ev->player_data = ecore_event_handler_add(
ECORE_EXE_EVENT_DATA, _player_data_cb, ev);
if (!_player_exec(ev))
{
ERR("could not start player.");
@ -998,15 +1030,13 @@ em_init(Evas_Object *obj, void **emotion_video, Emotion_Module_Options *opt)
ev->cmdline = eina_stringshare_add(player);
*emotion_video = ev;
return _fork_and_exec(obj, ev);
return _fork_and_exec(ev);
}
static int
em_shutdown(void *data)
static void
em_partial_shutdown(Emotion_Generic_Video *ev)
{
Emotion_Generic_Video *ev = data;
if (!ev) return 0;
_emotion_image_reset(ev->obj);
if (ev->player.exe)
{
@ -1017,20 +1047,39 @@ em_shutdown(void *data)
if (ev->shared)
munmap(ev->shared, ev->shared->size);
ev->shared = NULL;
if (ev->fd_read >= 0)
close(ev->fd_read);
ev->fd_read = -1;
if (ev->fd_write >= 0)
close(ev->fd_write);
ev->fd_write = -1;
if (ev->fd_handler)
ecore_main_fd_handler_del(ev->fd_handler);
ev->fd_handler = NULL;
if (ev->player_add) ecore_event_handler_del(ev->player_add);
ev->player_add = NULL;
if (ev->player_data) ecore_event_handler_del(ev->player_data);
ev->player_data = NULL;
if (ev->player_del) ecore_event_handler_del(ev->player_del);
ev->player_del = NULL;
if (ev->player_restart) ecore_idler_del(ev->player_restart);
ev->player_restart = NULL;
}
static int
em_shutdown(void *data)
{
Emotion_Generic_Video *ev = data;
if (!ev) return 0;
eina_stringshare_del(ev->cmdline);
eina_stringshare_del(ev->shmname);
ecore_event_handler_del(ev->player_add);
ecore_event_handler_del(ev->player_data);
ecore_event_handler_del(ev->player_del);
em_partial_shutdown(ev);
return 1;
}

View File

@ -67,6 +67,7 @@ struct _Emotion_Generic_Video
Emotion_Generic_Player player;
Emotion_Generic_Cmd_Buffer cmd;
Ecore_Event_Handler *player_add, *player_del, *player_data;
Ecore_Idler *player_restart;
int drop;
int fd_read, fd_write;
Ecore_Fd_Handler *fd_handler;