summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/lib/emotion_smart.c
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 /legacy/emotion/src/lib/emotion_smart.c
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_smart.c148
1 files changed, 99 insertions, 49 deletions
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,