From 1fb8ee18d98e68a48a9488429a76a7b0a21699f7 Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Fri, 30 Dec 2011 11:46:29 +0000 Subject: [PATCH] Emotion:fix compilation on Windows Note1: disable generic plugin on Windows as shm_open like function note implemented on that platform yet. Note2: want_module stuff must be fixed in the m4 macro Note3: abstract semaphore code in Eina ? SVN revision: 66686 --- legacy/emotion/configure.ac | 5 ++- legacy/emotion/src/bin/emotion_test_main.c | 5 ++- legacy/emotion/src/lib/emotion_main.c | 16 +++++--- legacy/emotion/src/lib/emotion_private.h | 12 ------ legacy/emotion/src/lib/emotion_smart.c | 27 ++++++++++---- .../modules/generic/Emotion_Generic_Plugin.h | 12 +++++- .../src/modules/generic/emotion_generic.c | 37 +++++++++++++++++-- .../src/modules/gstreamer/emotion_alloc.c | 11 +++++- .../src/modules/gstreamer/emotion_convert.c | 13 +++++++ .../src/modules/gstreamer/emotion_fakeeos.c | 13 +++++++ .../src/modules/gstreamer/emotion_gstreamer.c | 34 ++++++++++++++++- .../src/modules/gstreamer/emotion_gstreamer.h | 25 ------------- .../src/modules/gstreamer/emotion_sink.c | 26 +++++++++++-- 13 files changed, 173 insertions(+), 63 deletions(-) diff --git a/legacy/emotion/configure.ac b/legacy/emotion/configure.ac index 74edd37975..21305b423a 100644 --- a/legacy/emotion/configure.ac +++ b/legacy/emotion/configure.ac @@ -55,9 +55,10 @@ AC_SUBST(VMAJ) want_generic="yes" case "$host_os" in - mingw* | cegcc*) + mingw*) want_xine="no" want_gstreamer="yes" + want_generic="no" want_generic_vlc="no" ;; *) @@ -146,6 +147,8 @@ fi ### Checks for header files AC_HEADER_STDC +AC_CHECK_HEADERS([unistd.h]) + ### Checks for types diff --git a/legacy/emotion/src/bin/emotion_test_main.c b/legacy/emotion/src/bin/emotion_test_main.c index 548aea2411..1ea3865a3c 100644 --- a/legacy/emotion/src/bin/emotion_test_main.c +++ b/legacy/emotion/src/bin/emotion_test_main.c @@ -1,4 +1,7 @@ -#include "config.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include diff --git a/legacy/emotion/src/lib/emotion_main.c b/legacy/emotion/src/lib/emotion_main.c index d7d6902444..81809474fc 100644 --- a/legacy/emotion/src/lib/emotion_main.c +++ b/legacy/emotion/src/lib/emotion_main.c @@ -1,10 +1,13 @@ -#include "emotion_private.h" -#include "Emotion.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include #ifdef EMOTION_HAVE_EEZE -#include -#include -#include +# include +# include +# include # include # ifdef HAVE_V4L2 # include @@ -16,6 +19,9 @@ #include +#include "Emotion.h" +#include "emotion_private.h" + EAPI int EMOTION_WEBCAM_UPDATE = 0; struct ext_match_s diff --git a/legacy/emotion/src/lib/emotion_private.h b/legacy/emotion/src/lib/emotion_private.h index 7c5eb6e0aa..65954364a1 100644 --- a/legacy/emotion/src/lib/emotion_private.h +++ b/legacy/emotion/src/lib/emotion_private.h @@ -1,18 +1,6 @@ #ifndef EMOTION_PRIVATE_H #define EMOTION_PRIVATE_H -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include -#include - -#include -#include -#include - #define META_TRACK_TITLE 1 #define META_TRACK_ARTIST 2 #define META_TRACK_GENRE 3 diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c index 8a7ba22344..de31af8c17 100644 --- a/legacy/emotion/src/lib/emotion_smart.c +++ b/legacy/emotion/src/lib/emotion_smart.c @@ -1,11 +1,24 @@ -#include "emotion_private.h" -#include "Emotion.h" +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #ifdef HAVE_EIO # include # include #endif +#include "Emotion.h" +#include "emotion_private.h" + +#ifdef _WIN32 +# define FMT_UCHAR "%c" +#else +# define FMT_UCHAR "%hhu" +#endif + #define E_SMART_OBJ_GET(smart, o, type) \ { \ char *_e_smart_str; \ @@ -515,7 +528,7 @@ _emotion_object_aspect_border_apply(Evas_Object *obj, Smart_Data *sd, int w, int double ir; double r; - int aspect_opt; + int aspect_opt = 0; iw = sd->video.w; ih = sd->video.h; @@ -681,7 +694,7 @@ emotion_object_play_set(Evas_Object *obj, Eina_Bool play) Smart_Data *sd; E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); - DBG("play=%hhu, was=%hhu", play, sd->play); + DBG("play=" FMT_UCHAR ", was=" FMT_UCHAR, play, sd->play); if (play == sd->play) return; if (!sd->module) return; if (!sd->video_data) return; @@ -872,7 +885,7 @@ emotion_object_audio_mute_set(Evas_Object *obj, Eina_Bool mute) Smart_Data *sd; E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); - DBG("mute=%hhu", mute); + DBG("mute=" FMT_UCHAR, mute); if (!sd->module) return; if (!sd->video_data) return; sd->module->audio_channel_mute_set(sd->video_data, mute); @@ -940,7 +953,7 @@ emotion_object_video_mute_set(Evas_Object *obj, Eina_Bool mute) Smart_Data *sd; E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); - DBG("mute=%hhu", mute); + DBG("mute=" FMT_UCHAR, mute); if (!sd->module) return; if (!sd->video_data) return; sd->module->video_channel_mute_set(sd->video_data, mute); @@ -1008,7 +1021,7 @@ emotion_object_spu_mute_set(Evas_Object *obj, Eina_Bool mute) Smart_Data *sd; E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); - DBG("mute=%hhu", mute); + DBG("mute=" FMT_UCHAR, mute); if (!sd->module) return; if (!sd->video_data) return; sd->module->spu_channel_mute_set(sd->video_data, mute); diff --git a/legacy/emotion/src/modules/generic/Emotion_Generic_Plugin.h b/legacy/emotion/src/modules/generic/Emotion_Generic_Plugin.h index 4dd847319f..40a9b3164b 100644 --- a/legacy/emotion/src/modules/generic/Emotion_Generic_Plugin.h +++ b/legacy/emotion/src/modules/generic/Emotion_Generic_Plugin.h @@ -1,13 +1,18 @@ #ifndef EMOTION_GENERIC_PLUGIN_H #define EMOTION_GENERIC_PLUGIN_H -#include #include #include #include #include #include +#ifdef _WIN32 +# include +#else +#include +#endif + #define DEFAULTWIDTH 320 #define DEFAULTHEIGHT 240 #define DEFAULTPITCH 4 @@ -88,7 +93,12 @@ struct _Emotion_Generic_Video_Shared int last; int next; } frame; + /* FIXME: maybe abstracting that in Eina ? */ +#ifdef _WIN32 + HANDLE lock; +#else sem_t lock; +#endif int frame_drop; }; diff --git a/legacy/emotion/src/modules/generic/emotion_generic.c b/legacy/emotion/src/modules/generic/emotion_generic.c index 14156ab881..3ed8cfe8d9 100644 --- a/legacy/emotion/src/modules/generic/emotion_generic.c +++ b/legacy/emotion/src/modules/generic/emotion_generic.c @@ -1,14 +1,18 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif + #include #include #include #include #include #include +#include + #include #include +#include #include "Emotion.h" #include "emotion_private.h" @@ -161,7 +165,7 @@ _create_shm_data(Emotion_Generic_Video *ev, const char *shmname) vs = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0); if (vs == MAP_FAILED) { - ERR("error when mapping shared memory.\n"); + ERR("error when mapping shared memory"); return EINA_FALSE; } @@ -174,7 +178,17 @@ _create_shm_data(Emotion_Generic_Video *ev, const char *shmname) vs->frame.last = 2; vs->frame.next = 2; vs->frame_drop = 0; +#ifdef _WIN32 + /* FIXME: maximum count for the semaphore: 10. Is it sufficient ? */ + vs->lock = CreateSemaphore(NULL, 1, 10, NULL); + if (!vs->lock) + { + ERR("can not create semaphore"); + return EINA_FALSE; + } +#else sem_init(&vs->lock, 1, 1); +#endif ev->frame.frames[0] = (unsigned char *)vs + sizeof(*vs); ev->frame.frames[1] = (unsigned char *)vs + sizeof(*vs) + vs->height * vs->width * vs->pitch; ev->frame.frames[2] = (unsigned char *)vs + sizeof(*vs) + 2 * vs->height * vs->width * vs->pitch; @@ -469,7 +483,11 @@ static void _player_file_closed(Emotion_Generic_Video *ev) { INF("Closed previous file."); +#ifdef _WIN32 + CloseHandle(ev->shared->lock); +#else sem_destroy(&ev->shared->lock); +#endif ev->closing = EINA_FALSE; @@ -899,8 +917,8 @@ _player_exec(Emotion_Generic_Video *ev) ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_NOT_LEADER, ev); - INF("created pipe emotion -> player: %d -> %d\n", pipe_out[1], pipe_out[0]); - INF("created pipe player -> emotion: %d -> %d\n", pipe_in[1], pipe_in[0]); + INF("created pipe emotion -> player: %d -> %d", pipe_out[1], pipe_out[0]); + INF("created pipe player -> emotion: %d -> %d", pipe_in[1], pipe_in[0]); close(pipe_in[1]); close(pipe_out[0]); @@ -1239,12 +1257,21 @@ static int em_bgra_data_get(void *data, unsigned char **bgra_data) { Emotion_Generic_Video *ev = data; +#ifdef _WIN32 + DWORD res; +#endif if (!ev || !ev->file_ready) return 0; // lock frame here +#ifdef _WIN32 + res = WaitForSingleObject(ev->shared->lock, 0L); + if (res != WAIT_OBJECT_0) + return 0; +#else sem_wait(&ev->shared->lock); +#endif // send current frame to emotion if (ev->shared->frame.emotion != ev->shared->frame.last) @@ -1259,7 +1286,11 @@ em_bgra_data_get(void *data, unsigned char **bgra_data) ev->shared->frame_drop = 0; // unlock frame here +#ifdef _WIN32 + ReleaseSemaphore(ev->shared->lock, 1, NULL); +#else sem_post(&ev->shared->lock); +#endif ev->drop = 0; return 1; diff --git a/legacy/emotion/src/modules/gstreamer/emotion_alloc.c b/legacy/emotion/src/modules/gstreamer/emotion_alloc.c index aad5430a4c..70922a06f9 100644 --- a/legacy/emotion/src/modules/gstreamer/emotion_alloc.c +++ b/legacy/emotion/src/modules/gstreamer/emotion_alloc.c @@ -1,10 +1,17 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + #include #include #include #include -#include - +#include "Emotion.h" #include "emotion_gstreamer.h" Emotion_Gstreamer_Buffer * diff --git a/legacy/emotion/src/modules/gstreamer/emotion_convert.c b/legacy/emotion/src/modules/gstreamer/emotion_convert.c index c3d5d7233a..0b366879d5 100644 --- a/legacy/emotion/src/modules/gstreamer/emotion_convert.c +++ b/legacy/emotion/src/modules/gstreamer/emotion_convert.c @@ -1,3 +1,16 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include +#include +#include +#include + +#include "Emotion.h" #include "emotion_gstreamer.h" static inline void diff --git a/legacy/emotion/src/modules/gstreamer/emotion_fakeeos.c b/legacy/emotion/src/modules/gstreamer/emotion_fakeeos.c index 6ff20d2592..a2f3595094 100644 --- a/legacy/emotion/src/modules/gstreamer/emotion_fakeeos.c +++ b/legacy/emotion/src/modules/gstreamer/emotion_fakeeos.c @@ -1,3 +1,16 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include + +#include +#include +#include +#include + +#include "Emotion.h" #include "emotion_gstreamer.h" typedef struct _FakeEOSBin diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c index 7296cbb656..9f0051b7c0 100644 --- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c +++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c @@ -1,11 +1,35 @@ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifdef HAVE_UNISTD_H +# include +#endif #include #include +#include +#include +#define HTTP_STREAM 0 +#define RTSP_STREAM 1 +#include +#include +#include +#include +#include + +#ifdef HAVE_ECORE_X +# include +# include +# ifdef HAVE_XOVERLAY_H +# include +# endif +#endif + +#include "Emotion.h" #include "emotion_private.h" #include "emotion_gstreamer.h" -#include "Emotion.h" Eina_Bool window_manager_video = EINA_FALSE; int _emotion_gstreamer_log_domain = -1; @@ -400,9 +424,11 @@ em_cleanup(Emotion_Gstreamer_Video *ev) if (ev->xvpad) gst_object_unref(ev->xvpad); ev->xvpad = NULL; +#ifdef HAVE_ECORE_X fprintf(stderr, "destroying window: %i\n", ev->win); if (ev->win) ecore_x_window_free(ev->win); ev->win = 0; +#endif } EINA_LIST_FREE(ev->audio_streams, astream) @@ -1231,6 +1257,7 @@ em_priority_get(void *video) return ev->stream; } +#ifdef HAVE_ECORE_X static Eina_Bool _ecore_event_x_destroy(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) { @@ -1240,6 +1267,7 @@ _ecore_event_x_destroy(void *data __UNUSED__, int type __UNUSED__, void *event _ return EINA_TRUE; } +#endif static Eina_Bool module_open(Evas_Object *obj, @@ -1271,7 +1299,9 @@ module_open(Evas_Object *obj, if (!em_module.init(obj, video, opt)) return EINA_FALSE; +#ifdef HAVE_ECORE_X ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY, _ecore_event_x_destroy, NULL); +#endif if (getenv("EMOTION_FPS_DEBUG")) debug_fps = EINA_TRUE; diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.h b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.h index e69f30d486..25a718076c 100644 --- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.h +++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.h @@ -1,31 +1,6 @@ #ifndef __EMOTION_GSTREAMER_H__ #define __EMOTION_GSTREAMER_H__ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include - -#ifdef HAVE_ECORE_X -# include -# include -# ifdef HAVE_XOVERLAY_H -# include -# endif -#endif - -#define HTTP_STREAM 0 -#define RTSP_STREAM 1 -#include -#include -#include -#include -#include - -#include "emotion_private.h" - typedef void (*Evas_Video_Convert_Cb)(unsigned char *evas_data, const unsigned char *gst_data, unsigned int w, diff --git a/legacy/emotion/src/modules/gstreamer/emotion_sink.c b/legacy/emotion/src/modules/gstreamer/emotion_sink.c index 339a36c2a1..1e8b05098b 100644 --- a/legacy/emotion/src/modules/gstreamer/emotion_sink.c +++ b/legacy/emotion/src/modules/gstreamer/emotion_sink.c @@ -1,3 +1,21 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include + +#define HTTP_STREAM 0 +#define RTSP_STREAM 1 +#include +#include +#include +#include +#include + +#include "Emotion.h" +#include "emotion_private.h" #include "emotion_gstreamer.h" static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE("sink", @@ -831,9 +849,9 @@ static void _video_resize(void *data, Evas_Object *obj __UNUSED__, const Evas_Video_Surface *surface __UNUSED__, Evas_Coord w, Evas_Coord h) { +#ifdef HAVE_ECORE_X Emotion_Gstreamer_Video *ev = data; -#ifdef HAVE_ECORE_X ecore_x_window_resize(ev->win, w, h); #endif fprintf(stderr, "resize: %i, %i\n", w, h); @@ -843,8 +861,8 @@ static void _video_move(void *data, Evas_Object *obj __UNUSED__, const Evas_Video_Surface *surface __UNUSED__, Evas_Coord x, Evas_Coord y) { - Emotion_Gstreamer_Video *ev = data; #ifdef HAVE_ECORE_X + Emotion_Gstreamer_Video *ev = data; unsigned int pos[2]; fprintf(stderr, "move: %i, %i\n", x, y); @@ -890,10 +908,10 @@ _block_pad_link_cb(GstPad *pad, gboolean blocked, gpointer user_data) static void _video_show(void *data, Evas_Object *obj __UNUSED__, const Evas_Video_Surface *surface __UNUSED__) { +#ifdef HAVE_ECORE_X Emotion_Gstreamer_Video *ev = data; fprintf(stderr, "show xv\n"); -#ifdef HAVE_ECORE_X ecore_x_window_show(ev->win); #endif /* gst_pad_set_blocked_async(ev->teepad, TRUE, _block_pad_link_cb, ev); */ @@ -902,10 +920,10 @@ _video_show(void *data, Evas_Object *obj __UNUSED__, const Evas_Video_Surface *s static void _video_hide(void *data, Evas_Object *obj __UNUSED__, const Evas_Video_Surface *surface __UNUSED__) { +#ifdef HAVE_ECORE_X Emotion_Gstreamer_Video *ev = data; fprintf(stderr, "hide xv\n"); -#ifdef HAVE_ECORE_X ecore_x_window_hide(ev->win); #endif /* gst_pad_set_blocked_async(ev->teepad, TRUE, _block_pad_unlink_cb, ev); */