emotion/generic - Don't start opening new file when another one is being open.

SVN revision: 63203
This commit is contained in:
Rafael Antognolli 2011-09-05 16:07:00 +00:00
parent ce8904076d
commit dca7c873b2
3 changed files with 54 additions and 16 deletions

View File

@ -373,6 +373,13 @@ _event_cb(const struct libvlc_event_t *ev, void *data)
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);
@ -514,6 +521,9 @@ static void
_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);
@ -521,6 +531,8 @@ _file_close(struct _App *app)
}
app->closing = 1;
release_resources:
libvlc_media_player_stop(app->mp);
if (app->filename)
free(app->filename);

View File

@ -192,17 +192,6 @@ _player_new_frame(Emotion_Generic_Video *ev)
_emotion_frame_new(ev->obj);
}
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)
{
@ -220,6 +209,24 @@ _file_open(Emotion_Generic_Video *ev)
_player_send_str(ev, ev->filename, EINA_TRUE);
}
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)
{
@ -460,10 +467,17 @@ _player_open_done(Emotion_Generic_Video *ev)
{
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.");
@ -761,11 +775,19 @@ em_file_open(const char *file, Evas_Object *obj __UNUSED__, void *data)
INF("file set: %s", file);
if (!ev) return 0;
ev->pos = 0;
ev->opening = EINA_TRUE;
eina_stringshare_replace(&ev->filename, file);
ev->pos = 0;
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);
@ -783,6 +805,9 @@ em_file_close(void *data)
if (!ev->filename)
return;
if (ev->opening)
return;
_player_send_cmd(ev, EM_CMD_FILE_CLOSE);
ev->closing = EINA_TRUE;
}

View File

@ -56,6 +56,7 @@ struct _Emotion_Generic_Video
Eina_Bool seekable : 1;
volatile Eina_Bool opening : 1;
volatile Eina_Bool closing : 1;
Eina_Bool file_changed : 1;
int audio_channels_count;
int audio_channel_current;
struct _Emotion_Generic_Audio_Channel *audio_channels;