summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2009-12-30 10:49:06 +0000
committerCedric BAIL <cedric.bail@free.fr>2009-12-30 10:49:06 +0000
commit65c4336b0b6f436300c83c345ac999a6c3dc22f9 (patch)
tree54054308788092f1a5085fa9181c096e776ede67
parent1c1663bd88a72a7edcbe987fc6e2aff31a4b8c01 (diff)
* emotion: Switch to Eina module.
TODO: Add configure option to build module statically. SVN revision: 44781
Diffstat (limited to '')
-rw-r--r--legacy/emotion/src/lib/emotion_private.h20
-rw-r--r--legacy/emotion/src/lib/emotion_smart.c148
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c31
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer.h8
-rw-r--r--legacy/emotion/src/modules/vlc/emotion_vlc.c33
-rw-r--r--legacy/emotion/src/modules/vlc/emotion_vlc.h8
-rw-r--r--legacy/emotion/src/modules/xine/emotion_xine.c31
-rw-r--r--legacy/emotion/src/modules/xine/emotion_xine.h7
8 files changed, 196 insertions, 90 deletions
diff --git a/legacy/emotion/src/lib/emotion_private.h b/legacy/emotion/src/lib/emotion_private.h
index 3d352a4742..1fb6166391 100644
--- a/legacy/emotion/src/lib/emotion_private.h
+++ b/legacy/emotion/src/lib/emotion_private.h
@@ -26,6 +26,10 @@
26typedef enum _Emotion_Format Emotion_Format; 26typedef enum _Emotion_Format Emotion_Format;
27typedef struct _Emotion_Video_Module Emotion_Video_Module; 27typedef struct _Emotion_Video_Module Emotion_Video_Module;
28typedef struct _Emotion_Module_Options Emotion_Module_Options; 28typedef struct _Emotion_Module_Options Emotion_Module_Options;
29typedef struct _Eina_Emotion_Plugins Eina_Emotion_Plugins;
30
31typedef Eina_Bool (*Emotion_Module_Open)(Evas_Object *, const Emotion_Video_Module **, void **, Emotion_Module_Options *);
32typedef void (*Emotion_Module_Close)(Emotion_Video_Module *module, void *);
29 33
30enum _Emotion_Format 34enum _Emotion_Format
31{ 35{
@@ -38,8 +42,14 @@ enum _Emotion_Format
38 42
39struct _Emotion_Module_Options 43struct _Emotion_Module_Options
40{ 44{
41 unsigned char no_video : 1; 45 Eina_Bool no_video : 1;
42 unsigned char no_audio : 1; 46 Eina_Bool no_audio : 1;
47};
48
49struct _Eina_Emotion_Plugins
50{
51 Emotion_Module_Open open;
52 Emotion_Module_Close close;
43}; 53};
44 54
45struct _Emotion_Video_Module 55struct _Emotion_Video_Module
@@ -101,8 +111,7 @@ struct _Emotion_Video_Module
101 int (*eject) (void *ef); 111 int (*eject) (void *ef);
102 const char * (*meta_get) (void *ef, int meta); 112 const char * (*meta_get) (void *ef, int meta);
103 113
104 Ecore_Plugin *plugin; 114 Eina_Emotion_Plugins *plugin;
105 Ecore_Path_Group *path_group;
106}; 115};
107 116
108EAPI void *_emotion_video_get(Evas_Object *obj); 117EAPI void *_emotion_video_get(Evas_Object *obj);
@@ -119,4 +128,7 @@ EAPI void _emotion_file_ref_set(Evas_Object *obj, const char *file, int num);
119EAPI void _emotion_spu_button_num_set(Evas_Object *obj, int num); 128EAPI void _emotion_spu_button_num_set(Evas_Object *obj, int num);
120EAPI void _emotion_spu_button_set(Evas_Object *obj, int button); 129EAPI void _emotion_spu_button_set(Evas_Object *obj, int button);
121 130
131EAPI Eina_Bool _emotion_module_register(const char *name, Emotion_Module_Open open, Emotion_Module_Close close);
132EAPI Eina_Bool _emotion_module_unregister(const char *name);
133
122#endif 134#endif
diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c
index 71a60f3732..c9ceca373e 100644
--- a/legacy/emotion/src/lib/emotion_smart.c
+++ b/legacy/emotion/src/lib/emotion_smart.c
@@ -85,77 +85,78 @@ static void _smart_clip_unset(Evas_Object * obj);
85/* Globals for the E Video Object */ 85/* Globals for the E Video Object */
86/**********************************/ 86/**********************************/
87static Evas_Smart *smart = NULL; 87static Evas_Smart *smart = NULL;
88static Ecore_Path_Group *path_group = NULL; 88static Eina_Hash *_backends = NULL;
89static Eina_Array *_modules = NULL;
89 90
90static unsigned char 91EAPI Eina_Bool
92 _emotion_module_register(const char *name, Emotion_Module_Open open, Emotion_Module_Close close)
93{
94 Eina_Emotion_Plugins *plugin;
95
96 fprintf(stderr, "registering: %s\n", name);
97
98 plugin = malloc(sizeof (Eina_Emotion_Plugins));
99 if (!plugin) return EINA_FALSE;
100
101 plugin->open = open;
102 plugin->close = close;
103
104 return eina_hash_add(_backends, name, plugin);
105}
106
107EAPI Eina_Bool
108_emotion_module_unregister(const char *name)
109{
110 fprintf(stderr, "unregistering: %s\n", name);
111 return eina_hash_del(_backends, name, NULL);
112}
113
114static Eina_Bool
91_emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module **mod, void **video) 115_emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module **mod, void **video)
92{ 116{
93 Ecore_Plugin *plugin; 117 Eina_Emotion_Plugins *plugin;
94 char *tmp = NULL;
95 Smart_Data *sd; 118 Smart_Data *sd;
96 119
97 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0); 120 E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
98 if (!path_group) 121 if (!_backends)
99 path_group = ecore_path_group_new();
100 tmp = getenv("EMOTION_MODULES_DIR");
101 if (tmp)
102 ecore_path_group_add(path_group, tmp);
103 ecore_path_group_add(path_group, PACKAGE_LIB_DIR"/emotion/");
104 plugin = ecore_plugin_load(path_group, name, NULL);
105 if (plugin)
106 { 122 {
107 unsigned char (*func_module_open)(Evas_Object *, Emotion_Video_Module **, void **, Emotion_Module_Options *); 123 fprintf(stderr, "No backend loaded\n");
124 return EINA_FALSE;
125 }
108 126
109 func_module_open = ecore_plugin_symbol_get(plugin, "module_open"); 127 /* FIXME: Always look for a working backend. */
110 if (func_module_open) 128 plugin = eina_hash_find(_backends, name);
111 { 129 if (!plugin)
112 if (func_module_open(obj, mod, video, &(sd->module_options))) 130 {
113 { 131 fprintf(stderr, "No backend loaded\n");
114 if (*mod) 132 return EINA_FALSE;
115 {
116 (*mod)->plugin = plugin;
117 (*mod)->path_group = path_group;
118 return 1;
119 }
120 }
121 }
122 ecore_plugin_unload(plugin);
123 } 133 }
124 else
125 fprintf (stderr, "Unable to load module %s\n", name);
126 134
127 if (path_group) 135 if (plugin->open(obj, (const Emotion_Video_Module **) mod, video, &(sd->module_options)))
128 { 136 {
129 ecore_path_group_del(path_group); 137 if (*mod)
130 path_group = NULL; 138 {
139 (*mod)->plugin = plugin;
140 return EINA_TRUE;
141 }
131 } 142 }
132 143
133 return 0; 144 fprintf (stderr, "Unable to load module %s\n", name);
145
146 return EINA_FALSE;
134} 147}
135 148
136static void 149static void
137_emotion_module_close(Emotion_Video_Module *mod, void *video) 150_emotion_module_close(Emotion_Video_Module *mod, void *video)
138{ 151{
139 Ecore_Plugin *plugin;
140 void (*module_close) (Emotion_Video_Module *module, void *);
141 152
142 plugin = mod->plugin; 153 if (mod->plugin->close && video)
143 fprintf(stderr, "%p\n", plugin); 154 mod->plugin->close(mod, video);
144 module_close = ecore_plugin_symbol_get(mod->plugin, "module_close");
145 if ((module_close) && (video)) module_close(mod, video);
146 /* FIXME: we can't go dlclosing here as a thread still may be running from 155 /* FIXME: we can't go dlclosing here as a thread still may be running from
147 * the module - this in theory will leak- but it shouldnt be too bad and 156 * the module - this in theory will leak- but it shouldnt be too bad and
148 * mean that once a module is dlopened() it cant be closed - its refcount 157 * mean that once a module is dlopened() it cant be closed - its refcount
149 * will just keep going up 158 * will just keep going up
150 */ 159 */
151 /*
152 ecore_plugin_unload(plugin);
153 */
154 if (path_group)
155 {
156 ecore_path_group_del(path_group);
157 path_group = NULL;
158 }
159} 160}
160 161
161/*******************************/ 162/*******************************/
@@ -180,11 +181,11 @@ emotion_object_module_option_set(Evas_Object *obj, const char *opt, const char *
180 if ((!opt) || (!val)) return; 181 if ((!opt) || (!val)) return;
181 if (!strcmp(opt, "video")) 182 if (!strcmp(opt, "video"))
182 { 183 {
183 if (!strcmp(val, "off")) sd->module_options.no_video = 1; 184 if (!strcmp(val, "off")) sd->module_options.no_video = EINA_TRUE;
184 } 185 }
185 else if (!strcmp(opt, "audio")) 186 else if (!strcmp(opt, "audio"))
186 { 187 {
187 if (!strcmp(val, "off")) sd->module_options.no_audio = 1; 188 if (!strcmp(val, "off")) sd->module_options.no_audio = EINA_TRUE;
188 } 189 }
189} 190}
190 191
@@ -1181,11 +1182,60 @@ _pixels_get(void *data, Evas_Object *obj)
1181/*******************************************/ 1182/*******************************************/
1182/* Internal smart object required routines */ 1183/* Internal smart object required routines */
1183/*******************************************/ 1184/*******************************************/
1185#ifdef EINA_STATIC_BUILD_XINE
1186Eina_Bool xine_module_init(void);
1187#endif
1188#ifdef EINA_STATIC_BUILD_VLC
1189Eina_Bool vlc_module_init(void);
1190#endif
1191#ifdef EINA_STATIC_BUILD_GSTREAMER
1192Eina_Bool gstreamer_module_init(void);
1193#endif
1194
1184static void 1195static void
1185_smart_init(void) 1196_smart_init(void)
1186{ 1197{
1198 char *path;
1199
1187 if (smart) return; 1200 if (smart) return;
1188 { 1201 {
1202 eina_init();
1203
1204 _backends = eina_hash_string_small_new(free);
1205
1206 _modules = eina_module_list_get(NULL, PACKAGE_LIB_DIR "/eina/mp/", 0, NULL, NULL);
1207
1208 path = eina_module_environment_path_get("HOME", "/.emotion/");
1209 _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
1210 if (path) free(path);
1211
1212 path = eina_module_environment_path_get("EMOTION_MODULES_DIR", "/emotion/");
1213 _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
1214 if (path) free(path);
1215
1216 path = eina_module_symbol_path_get(emotion_object_add, "/emotion/");
1217 _modules = eina_module_list_get(_modules, path, 0, NULL, NULL);
1218 if (path) free(path);
1219
1220 if (!_modules)
1221 {
1222 fprintf(stderr, "No module found !\n");
1223 return ;
1224 }
1225
1226 eina_module_list_load(_modules);
1227
1228 /* Init static module */
1229#ifdef EINA_STATIC_BUILD_XINE
1230 xine_module_init();
1231#endif
1232#ifdef EINA_STATIC_BUILD_VLC
1233 vlc_module_init();
1234#endif
1235#ifdef EINA_STATIC_BUILD_GSTREAMER
1236 gstreamer_module_init();
1237#endif
1238
1189 static const Evas_Smart_Class sc = 1239 static const Evas_Smart_Class sc =
1190 { 1240 {
1191 E_OBJ_NAME, 1241 E_OBJ_NAME,
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
index 96d153ce4d..0de2cb029d 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
@@ -1257,29 +1257,48 @@ em_meta_get(void *video, int meta)
1257 return str; 1257 return str;
1258} 1258}
1259 1259
1260EAPI unsigned char 1260static Eina_Bool
1261module_open(Evas_Object *obj, 1261module_open(Evas_Object *obj,
1262 Emotion_Video_Module **module, 1262 const Emotion_Video_Module **module,
1263 void **video, 1263 void **video,
1264 Emotion_Module_Options *opt) 1264 Emotion_Module_Options *opt)
1265{ 1265{
1266 if (!module) 1266 if (!module)
1267 return 0; 1267 return EINA_FALSE;
1268 1268
1269 if (!em_module.init(obj, video, opt)) 1269 if (!em_module.init(obj, video, opt))
1270 return 0; 1270 return EINA_FALSE;
1271 1271
1272 *module = &em_module; 1272 *module = &em_module;
1273 return 1; 1273 return EINA_TRUE;
1274} 1274}
1275 1275
1276EAPI void 1276static void
1277module_close(Emotion_Video_Module *module, 1277module_close(Emotion_Video_Module *module,
1278 void *video) 1278 void *video)
1279{ 1279{
1280 em_module.shutdown(video); 1280 em_module.shutdown(video);
1281} 1281}
1282 1282
1283Eina_Bool
1284gstreamer_module_init(void)
1285{
1286 return _emotion_module_register("gstreamer", module_open, module_close);
1287}
1288
1289void
1290gstreamer_module_shutdown(void)
1291{
1292 _emotion_module_unregister("gstreamer");
1293}
1294
1295#ifndef EINA_STATIC_BUILD_GSTREAMER
1296
1297EINA_MODULE_INIT(gstreamer_module_init);
1298EINA_MODULE_SHUTDOWN(gstreamer_module_shutdown);
1299
1300#endif
1301
1283static void 1302static void
1284_for_each_tag(GstTagList const* list, 1303_for_each_tag(GstTagList const* list,
1285 gchar const* tag, 1304 gchar const* tag,
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.h b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.h
index 35814307df..877d5eb8da 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.h
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.h
@@ -95,12 +95,4 @@ struct _Emotion_Gstreamer_Video
95 unsigned char audio_mute : 1; 95 unsigned char audio_mute : 1;
96}; 96};
97 97
98EAPI unsigned char module_open(Evas_Object *obj,
99 Emotion_Video_Module **module,
100 void **video, Emotion_Module_Options *opt);
101
102EAPI void module_close(Emotion_Video_Module *module,
103 void *video);
104
105
106#endif /* __EMOTION_GSTREAMER_H__ */ 98#endif /* __EMOTION_GSTREAMER_H__ */
diff --git a/legacy/emotion/src/modules/vlc/emotion_vlc.c b/legacy/emotion/src/modules/vlc/emotion_vlc.c
index 0741c0b869..7f641802a9 100644
--- a/legacy/emotion/src/modules/vlc/emotion_vlc.c
+++ b/legacy/emotion/src/modules/vlc/emotion_vlc.c
@@ -1201,25 +1201,46 @@ static Emotion_Video_Module em_module =
1201 NULL /* handle */ 1201 NULL /* handle */
1202}; 1202};
1203 1203
1204unsigned char module_open(Evas_Object *obj, const Emotion_Video_Module **module, void **video, Emotion_Module_Options *opt) 1204static Eina_Bool module_open(Evas_Object *obj, const Emotion_Video_Module **module, void **video, Emotion_Module_Options *opt)
1205{ 1205{
1206 if (!module) { 1206 if (!module) {
1207 return 0; 1207 return EINA_FALSE;
1208 } 1208 }
1209 1209
1210 if (!em_module.init(obj, video, opt)) { 1210 if (!em_module.init(obj, video, opt)) {
1211 return 0; 1211 return EINA_FALSE;
1212 } 1212 }
1213 1213
1214 *module = &em_module; 1214 *module = &em_module;
1215 1215
1216 return 1; 1216 return EINA_TRUE;
1217} 1217}
1218 1218
1219void module_close(Emotion_Video_Module *module, void *video) 1219static void module_close(Emotion_Video_Module *module, void *video)
1220{ 1220{
1221 em_module.shutdown(video); 1221 em_module.shutdown(video);
1222} 1222}
1223 1223
1224
1225Eina_Bool
1226vlc_module_init(void)
1227{
1228 return _emotion_module_register("vlc", module_open, module_close);
1229}
1230
1231void
1232vlc_module_shutdown(void)
1233{
1234 _emotion_module_unregister("vlc");
1235}
1236
1237#ifndef EINA_STATIC_BUILD_VLC
1238
1239EINA_MODULE_INIT(vlc_module_init);
1240EINA_MODULE_SHUTDOWN(vlc_module_shutdown);
1241
1242#endif
1243
1244
1224#endif /* EMOTION_VLC_C */ 1245#endif /* EMOTION_VLC_C */
1225 1246
diff --git a/legacy/emotion/src/modules/vlc/emotion_vlc.h b/legacy/emotion/src/modules/vlc/emotion_vlc.h
index c2c073f552..2db3d94097 100644
--- a/legacy/emotion/src/modules/vlc/emotion_vlc.h
+++ b/legacy/emotion/src/modules/vlc/emotion_vlc.h
@@ -99,10 +99,6 @@ static double em_speed_get (void *ef);
99static int em_eject (void *ef); 99static int em_eject (void *ef);
100static const char *em_meta_get (void *ef, int meta); 100static const char *em_meta_get (void *ef, int meta);
101 101
102/* entry points for module */
103unsigned char module_open(Evas_Object *obj, const Emotion_Video_Module **module, void **video, Emotion_Module_Options *opt);
104void module_close(Emotion_Video_Module *module, void *video);
105
106typedef struct _vlc_event_t { 102typedef struct _vlc_event_t {
107 libvlc_event_type_t type; 103 libvlc_event_type_t type;
108 int data_length; 104 int data_length;
@@ -145,8 +141,8 @@ struct _Emotion_Vlc_Video
145 unsigned char video_mute : 1; 141 unsigned char video_mute : 1;
146 unsigned char audio_mute : 1; 142 unsigned char audio_mute : 1;
147 unsigned char spu_mute : 1; 143 unsigned char spu_mute : 1;
148 unsigned char opt_no_video : 1; 144 Eina_Bool opt_no_video : 1;
149 unsigned char opt_no_audio : 1; 145 Eina_Bool opt_no_audio : 1;
150 volatile unsigned char delete_me : 1; 146 volatile unsigned char delete_me : 1;
151 volatile unsigned char opening : 1; 147 volatile unsigned char opening : 1;
152 volatile unsigned char closing : 1; 148 volatile unsigned char closing : 1;
diff --git a/legacy/emotion/src/modules/xine/emotion_xine.c b/legacy/emotion/src/modules/xine/emotion_xine.c
index 704e60f0b5..15d1556843 100644
--- a/legacy/emotion/src/modules/xine/emotion_xine.c
+++ b/legacy/emotion/src/modules/xine/emotion_xine.c
@@ -1526,25 +1526,44 @@ static Emotion_Video_Module em_module =
1526 NULL /* handle */ 1526 NULL /* handle */
1527}; 1527};
1528 1528
1529EAPI unsigned char 1529static Eina_Bool
1530module_open(Evas_Object *obj, const Emotion_Video_Module **module, void **video, Emotion_Module_Options *opt) 1530module_open(Evas_Object *obj, const Emotion_Video_Module **module, void **video, Emotion_Module_Options *opt)
1531{ 1531{
1532 if (!module) 1532 if (!module)
1533 return 0; 1533 return EINA_FALSE;
1534 1534
1535 if (!em_module.init(obj, video, opt)) 1535 if (!em_module.init(obj, video, opt))
1536 return 0; 1536 return EINA_FALSE;
1537 1537
1538 *module = &em_module; 1538 *module = &em_module;
1539 return 1; 1539 return EINA_TRUE;
1540} 1540}
1541 1541
1542EAPI void 1542static void
1543module_close(Emotion_Video_Module *module, void *video) 1543module_close(Emotion_Video_Module *module, void *video)
1544{ 1544{
1545 em_module.shutdown(video); 1545 em_module.shutdown(video);
1546} 1546}
1547 1547
1548Eina_Bool
1549xine_module_init(void)
1550{
1551 return _emotion_module_register("xine", module_open, module_close);
1552}
1553
1554void
1555xine_module_shutdown(void)
1556{
1557 _emotion_module_unregister("xine");
1558}
1559
1560#ifndef EINA_STATIC_BUILD_XINE
1561
1562EINA_MODULE_INIT(xine_module_init);
1563EINA_MODULE_SHUTDOWN(xine_module_shutdown);
1564
1565#endif
1566
1548#if 0 1567#if 0
1549void 1568void
1550em_debug(Emotion_Xine_Video *ev) 1569em_debug(Emotion_Xine_Video *ev)
diff --git a/legacy/emotion/src/modules/xine/emotion_xine.h b/legacy/emotion/src/modules/xine/emotion_xine.h
index 3a4b464a20..e5cf122588 100644
--- a/legacy/emotion/src/modules/xine/emotion_xine.h
+++ b/legacy/emotion/src/modules/xine/emotion_xine.h
@@ -43,8 +43,8 @@ struct _Emotion_Xine_Video
43 unsigned char video_mute : 1; 43 unsigned char video_mute : 1;
44 unsigned char audio_mute : 1; 44 unsigned char audio_mute : 1;
45 unsigned char spu_mute : 1; 45 unsigned char spu_mute : 1;
46 unsigned char opt_no_video : 1; 46 Eina_Bool opt_no_video : 1;
47 unsigned char opt_no_audio : 1; 47 Eina_Bool opt_no_audio : 1;
48 volatile unsigned char delete_me : 1; 48 volatile unsigned char delete_me : 1;
49 volatile unsigned char no_time : 1; 49 volatile unsigned char no_time : 1;
50 volatile unsigned char opening : 1; 50 volatile unsigned char opening : 1;
@@ -85,7 +85,4 @@ struct _Emotion_Xine_Event
85 int mtype; 85 int mtype;
86}; 86};
87 87
88EAPI unsigned char module_open(Evas_Object *obj, const Emotion_Video_Module **module, void **video, Emotion_Module_Options *opt);
89EAPI void module_close(Emotion_Video_Module *module, void *video);
90
91#endif 88#endif