do you know that eina_file has some mmap wrapper that is cross platform ? Vincent
On Mon, 5 Sep 2011, Enlightenment SVN wrote: > Log: > 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. > > Author: antognolli > Date: 2011-09-05 06:11:53 -0700 (Mon, 05 Sep 2011) > New Revision: 63197 > Trac: http://trac.enlightenment.org/e/changeset/63197 > > Modified: > trunk/emotion/src/generic_players/vlc/emotion_generic_vlc.c > trunk/emotion/src/modules/generic/Emotion_Generic_Plugin.h > trunk/emotion/src/modules/generic/emotion_generic.c > > Modified: trunk/emotion/src/generic_players/vlc/emotion_generic_vlc.c > =================================================================== > --- trunk/emotion/src/generic_players/vlc/emotion_generic_vlc.c > 2011-09-05 12:48:02 UTC (rev 63196) > +++ trunk/emotion/src/generic_players/vlc/emotion_generic_vlc.c > 2011-09-05 13:11:53 UTC (rev 63197) > @@ -471,12 +471,27 @@ > 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 @@ > _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 > > Modified: trunk/emotion/src/modules/generic/Emotion_Generic_Plugin.h > =================================================================== > --- trunk/emotion/src/modules/generic/Emotion_Generic_Plugin.h > 2011-09-05 12:48:02 UTC (rev 63196) > +++ trunk/emotion/src/modules/generic/Emotion_Generic_Plugin.h > 2011-09-05 13:11:53 UTC (rev 63197) > @@ -23,7 +23,7 @@ > 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 @@ > 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_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; > > Modified: trunk/emotion/src/modules/generic/emotion_generic.c > =================================================================== > --- trunk/emotion/src/modules/generic/emotion_generic.c 2011-09-05 > 12:48:02 UTC (rev 63196) > +++ trunk/emotion/src/modules/generic/emotion_generic.c 2011-09-05 > 13:11:53 UTC (rev 63197) > @@ -140,6 +140,12 @@ > 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 @@ > { > 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 @@ > } > > 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_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); > > > ------------------------------------------------------------------------------ > Special Offer -- Download ArcSight Logger for FREE! > Finally, a world-class log management solution at an even better > price-free! And you'll get a free "Love Thy Logs" t-shirt when you > download Logger. Secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsisghtdev2dev > _______________________________________________ > enlightenment-svn mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn > > ------------------------------------------------------------------------------ Special Offer -- Download ArcSight Logger for FREE! Finally, a world-class log management solution at an even better price-free! And you'll get a free "Love Thy Logs" t-shirt when you download Logger. Secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsisghtdev2dev _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
