static void
_file_set(struct _App *app)
{
+ if (app->opening)
+ {
+ libvlc_media_release(app->m);
+ libvlc_media_player_release(app->mp);
+ free(app->filename);
+ }
+
_em_str_read(app->em_read, &app->filename);
app->m = libvlc_media_new_path(app->libvlc, app->filename);
_file_close(struct _App *app)
{
app->playing = 0;
+ if (app->opening)
+ goto release_resources;
+
if (libvlc_media_player_get_state(app->mp) != libvlc_Playing)
{
_send_file_closed(app);
}
app->closing = 1;
+
+release_resources:
libvlc_media_player_stop(app->mp);
if (app->filename)
free(app->filename);
}
static void
-_player_file_set_done(Emotion_Generic_Video *ev)
-{
- if (!_create_shm_data(ev, ev->shmname))
- {
- ERR("could not create shared memory.");
- return;
- }
- _player_send_cmd(ev, EM_CMD_FILE_SET_DONE);
-}
-
-static void
_file_open(Emotion_Generic_Video *ev)
{
INF("Opening file: %s", ev->filename);
}
static void
+_player_file_set_done(Emotion_Generic_Video *ev)
+{
+ if (ev->file_changed)
+ {
+ _file_open(ev);
+ ev->file_changed = EINA_FALSE;
+ return;
+ }
+
+ if (!_create_shm_data(ev, ev->shmname))
+ {
+ ERR("could not create shared memory.");
+ return;
+ }
+ _player_send_cmd(ev, EM_CMD_FILE_SET_DONE);
+}
+
+static void
_player_ready(Emotion_Generic_Video *ev)
{
INF("received: player ready.");
{
int success;
- ev->opening = EINA_FALSE;
_player_int_read(ev, &success);
-
shm_unlink(ev->shmname);
+
+ if (ev->file_changed)
+ {
+ _file_open(ev);
+ ev->file_changed = EINA_FALSE;
+ return;
+ }
+
+ ev->opening = EINA_FALSE;
if (!success)
{
ERR("Could not open file.");
INF("file set: %s", file);
if (!ev) return 0;
+ eina_stringshare_replace(&ev->filename, file);
+
ev->pos = 0;
- ev->opening = EINA_TRUE;
- eina_stringshare_replace(&ev->filename, file);
+ if (ev->ready && ev->opening)
+ {
+ INF("file changed while opening.");
+ ev->file_changed = EINA_TRUE;
+ return 1;
+ }
+
+ ev->opening = EINA_TRUE;
if (!ev->closing)
_file_open(ev);
if (!ev->filename)
return;
+ if (ev->opening)
+ return;
+
_player_send_cmd(ev, EM_CMD_FILE_CLOSE);
ev->closing = EINA_TRUE;
}