forked from enlightenment/efl
emotion/generic: Add return value to EM_RESULT_FILE_SET_DONE.
It now checks if was possible to get the shared memory, and returns true or false. This will command will also be used later to return false for file opening no matter what was the problem, and maybe the int parameter will indicate the type of error. SVN revision: 63197
This commit is contained in:
parent
9182147b5f
commit
733fe1d444
|
@ -471,12 +471,27 @@ _audio_track_set(struct _App *app)
|
|||
static void
|
||||
_file_set_done(struct _App *app)
|
||||
{
|
||||
emotion_generic_shm_get(app->shmname, &app->vs, &app->vf);
|
||||
int r;
|
||||
|
||||
app->opening = 0;
|
||||
|
||||
r = emotion_generic_shm_get(app->shmname, &app->vs, &app->vf);
|
||||
if (!r)
|
||||
{
|
||||
free(app->filename);
|
||||
libvlc_media_release(app->m);
|
||||
libvlc_media_player_release(app->mp);
|
||||
app->filename = NULL;
|
||||
app->m = NULL;
|
||||
app->mp = NULL;
|
||||
_send_cmd_start(EM_RESULT_FILE_SET_DONE);
|
||||
SEND_CMD_PARAM(r);
|
||||
_send_cmd_finish();
|
||||
}
|
||||
app->w = app->vs->width;
|
||||
app->h = app->vs->height;
|
||||
libvlc_video_set_format(app->mp, "RV32", app->w, app->h, app->w * 4);
|
||||
libvlc_video_set_callbacks(app->mp, _lock, _unlock, _display, app);
|
||||
app->opening = 0;
|
||||
|
||||
|
||||
libvlc_event_attach(app->event_mgr, libvlc_MediaPlayerPlaying,
|
||||
|
@ -489,7 +504,10 @@ _file_set_done(struct _App *app)
|
|||
_event_cb, app);
|
||||
|
||||
libvlc_audio_set_mute(app->mp, 0);
|
||||
_send_cmd(EM_RESULT_FILE_SET_DONE);
|
||||
|
||||
_send_cmd_start(EM_RESULT_FILE_SET_DONE);
|
||||
SEND_CMD_PARAM(r);
|
||||
_send_cmd_finish();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -23,7 +23,7 @@ enum _Emotion_Generic_Cmd
|
|||
EM_CMD_PLAY, // param: position (float)
|
||||
EM_CMD_STOP, // param: none
|
||||
EM_CMD_FILE_SET, // param: filename (string)
|
||||
EM_CMD_FILE_SET_DONE, // param: none
|
||||
EM_CMD_FILE_SET_DONE, // param: success (int)
|
||||
EM_CMD_FILE_CLOSE, // param: none
|
||||
EM_CMD_POSITION_SET, // param: position (float)
|
||||
EM_CMD_SPEED_SET, // param: speed (float)
|
||||
|
@ -84,7 +84,7 @@ struct _Emotion_Generic_Video_Shared
|
|||
sem_t lock;
|
||||
};
|
||||
|
||||
inline void
|
||||
inline int
|
||||
emotion_generic_shm_get(const char *shmname, Emotion_Generic_Video_Shared **vs, Emotion_Generic_Video_Frame *vf)
|
||||
{
|
||||
int shmfd = -1;
|
||||
|
@ -92,11 +92,29 @@ emotion_generic_shm_get(const char *shmname, Emotion_Generic_Video_Shared **vs,
|
|||
Emotion_Generic_Video_Shared *t_vs;
|
||||
|
||||
shmfd = shm_open(shmname, O_RDWR, 0777);
|
||||
if (shmfd == -1)
|
||||
{
|
||||
fprintf(stderr, "player: could not open shm: %s\n", shmname);
|
||||
fprintf(stderr, "player: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
t_vs = mmap(NULL, sizeof(*t_vs), PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0);
|
||||
if (t_vs == MAP_FAILED)
|
||||
{
|
||||
fprintf(stderr, "player: could not map shared memory.\n");
|
||||
fprintf(stderr, "player: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
size = t_vs->size;
|
||||
munmap(t_vs, sizeof(*t_vs));
|
||||
t_vs = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0);
|
||||
if (t_vs == MAP_FAILED)
|
||||
{
|
||||
fprintf(stderr, "player: could not map shared memory.\n");
|
||||
fprintf(stderr, "player: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
vf->frames[0] = (unsigned char *)t_vs + sizeof(*t_vs);
|
||||
vf->frames[1] = (unsigned char *)t_vs + sizeof(*t_vs) + t_vs->height * t_vs->width * t_vs->pitch;
|
||||
|
|
|
@ -140,6 +140,12 @@ _create_shm_data(Emotion_Generic_Video *ev, const char *shmname)
|
|||
Emotion_Generic_Video_Shared *vs;
|
||||
|
||||
shmfd = shm_open(shmname, O_CREAT | O_RDWR | O_TRUNC, 0777);
|
||||
if (shmfd == -1)
|
||||
{
|
||||
ERR("player: could not open shm: %s", shmname);
|
||||
ERR("player: %s", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
size = 3 * (ev->w * ev->h * DEFAULTPITCH) + sizeof(*vs);
|
||||
|
||||
npages = (int)(size / getpagesize()) + 1;
|
||||
|
@ -149,6 +155,7 @@ _create_shm_data(Emotion_Generic_Video *ev, const char *shmname)
|
|||
{
|
||||
ERR("error when allocating shared memory (size = %zd): "
|
||||
"%s", size, strerror(errno));
|
||||
shm_unlink(shmname);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
vs = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0);
|
||||
|
@ -386,10 +393,20 @@ _player_file_closed(Emotion_Generic_Video *ev)
|
|||
}
|
||||
|
||||
static void
|
||||
_player_open_done(Emotion_Generic_Video *ev)
|
||||
_player_open_done(Emotion_Generic_Video *ev, void *line)
|
||||
{
|
||||
int success;
|
||||
|
||||
ev->opening = EINA_FALSE;
|
||||
RCV_CMD_PARAM(line, success);
|
||||
|
||||
shm_unlink(ev->shmname);
|
||||
if (!success)
|
||||
{
|
||||
ERR("Could not open file.");
|
||||
return;
|
||||
}
|
||||
|
||||
_emotion_open_done(ev->obj);
|
||||
|
||||
if (ev->play)
|
||||
|
@ -418,7 +435,7 @@ _player_read_cmd(Emotion_Generic_Video *ev, void *line, int size __UNUSED__)
|
|||
_player_file_set_done(ev);
|
||||
break;
|
||||
case EM_RESULT_FILE_SET_DONE:
|
||||
_player_open_done(ev);
|
||||
_player_open_done(ev, line);
|
||||
break;
|
||||
case EM_RESULT_FILE_CLOSE:
|
||||
_player_file_closed(ev);
|
||||
|
|
Loading…
Reference in New Issue