summaryrefslogtreecommitdiff
path: root/src/lib/emotion/emotion_modules.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-27 17:14:02 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-27 17:18:01 +0900
commitc8630c85a13fa04c63497a1ba29dc35ed8e419b0 (patch)
tree29e07e0ae1d59a7193e37b2489d88d20d97e902e /src/lib/emotion/emotion_modules.c
parentf24164637085d006b82b91d4bf57f35d3520d97d (diff)
emotion - broken module loading loagic fixed that fixes gst 0.10/1 deadlock
so firstly the module loading logic in emotion is pretty bad. it forcible loads into memory (dlopen + run code from) EVERY emotion module whenever you use emotion anywhere. this is a fat memory cost and startup cost. it should not ever have done this. so remove that code and make it explicitly load only the backend requested and fall back to using what is compiled in (generic by default) and otherwise generic as a module, then xine, then gstreamer then gstreamer1. gstreamer1 seems broke - all i see is a black box (no video). this also fixes a deadlock problem. if you have BOTH gstreamer AND gstreamer1 modules loaded i get a deadlock inside glib. this seemingly fixes it as it'll only load the first one it finds, not both (unless explicitly requested).
Diffstat (limited to 'src/lib/emotion/emotion_modules.c')
-rw-r--r--src/lib/emotion/emotion_modules.c89
1 files changed, 80 insertions, 9 deletions
diff --git a/src/lib/emotion/emotion_modules.c b/src/lib/emotion/emotion_modules.c
index 1ba3c10bc1..e6c5640a55 100644
--- a/src/lib/emotion/emotion_modules.c
+++ b/src/lib/emotion/emotion_modules.c
@@ -83,8 +83,7 @@ _emotion_modules_load(void)
83 _emotion_modules = eina_module_list_get(_emotion_modules, buf, 83 _emotion_modules = eina_module_list_get(_emotion_modules, buf,
84 EINA_FALSE, NULL, NULL); 84 EINA_FALSE, NULL, NULL);
85 } 85 }
86 86 return;
87 goto load;
88 } 87 }
89 } 88 }
90 89
@@ -105,13 +104,16 @@ _emotion_modules_load(void)
105 104
106 snprintf(buf, sizeof(buf), "%s/emotion/modules", eina_prefix_lib_get(_emotion_pfx)); 105 snprintf(buf, sizeof(buf), "%s/emotion/modules", eina_prefix_lib_get(_emotion_pfx));
107 _emotion_modules = eina_module_arch_list_get(_emotion_modules, buf, MODULE_ARCH); 106 _emotion_modules = eina_module_arch_list_get(_emotion_modules, buf, MODULE_ARCH);
108 107// no - this is dumb. load ALL modules we find - force ALL the code pages of
109 load: 108// every lib a module MAY depend on and need to execute some init code into
110 if (_emotion_modules) 109// memory even if we never use it? not a good idea! the point of modules was
111 eina_module_list_load(_emotion_modules); 110// to avoid such cost until a module is EXPLICITLY asked for.
112 111//load:
113 if (!_emotion_engine_registry) 112// if (_emotion_modules)
114 ERR("Couldn't find any emotion engine."); 113// eina_module_list_load(_emotion_modules);
114//
115// if (!_emotion_engine_registry)
116// ERR("Couldn't find any emotion engine.");
115} 117}
116 118
117Eina_Bool 119Eina_Bool
@@ -291,6 +293,57 @@ _emotion_engine_instance_new(const Emotion_Engine *engine, Evas_Object *obj, voi
291 return NULL; 293 return NULL;
292} 294}
293 295
296static Eina_Module *
297_find_mod(const char *name)
298{
299 Eina_Array_Iterator iterator;
300 Eina_Module *m;
301 unsigned int i;
302 int inlen;
303
304 if (!name) return NULL;
305 inlen = strlen(name);
306 EINA_ARRAY_ITER_NEXT(_emotion_modules, i, m, iterator)
307 {
308 const char *path = eina_module_file_get(m);
309 const char *p, *p1, *p2;
310 int found, len;
311
312 if ((!path) || (!path[0])) continue;
313 // path is /*/modulename/ARCH/module.* - we want "modulename"
314 found = 0;
315 p1 = p2 = NULL;
316 for (p = path + strlen(path) - 1;
317 p > path;
318 p--)
319 {
320 if (*p == '/')
321 {
322 found++;
323 // found == 1 -> p = /module.*
324 // found == 2 -> p = /ARCH/module.*
325 // found == 3 -> p = /modulename/ARCH/module.*
326 if (found == 2) p2 = p;
327 if (found == 3)
328 {
329 p1 = p;
330 break;
331 }
332 }
333 }
334 if (p1)
335 {
336 p1++;
337 len = p2 - p1;
338 if (len == inlen)
339 {
340 if (!strncmp(p1, name, len)) return m;
341 }
342 }
343 }
344 return NULL;
345}
346
294Emotion_Engine_Instance * 347Emotion_Engine_Instance *
295emotion_engine_instance_new(const char *name, Evas_Object *obj, Emotion_Module_Options *opts) 348emotion_engine_instance_new(const char *name, Evas_Object *obj, Emotion_Module_Options *opts)
296{ 349{
@@ -298,6 +351,7 @@ emotion_engine_instance_new(const char *name, Evas_Object *obj, Emotion_Module_O
298 const Emotion_Engine_Registry_Entry *re; 351 const Emotion_Engine_Registry_Entry *re;
299 const Emotion_Engine *engine; 352 const Emotion_Engine *engine;
300 void *data; 353 void *data;
354 Eina_Module *m;
301 355
302 _emotion_modules_load(); 356 _emotion_modules_load();
303 357
@@ -309,6 +363,23 @@ emotion_engine_instance_new(const char *name, Evas_Object *obj, Emotion_Module_O
309 363
310 if (name) 364 if (name)
311 { 365 {
366 m = _find_mod(name);
367 if (m) eina_module_load(m);
368 }
369 else
370 {
371 if (!_emotion_engine_registry)
372 {
373 m = _find_mod("generic");
374 if (!m) m = _find_mod("xine");
375 if (!m) m = _find_mod("gstreamer");
376 if (!m) m = _find_mod("gstreamer1");
377 if (m) eina_module_load(m);
378 }
379 }
380
381 if (name)
382 {
312 engine = _emotion_engine_registry_find(name); 383 engine = _emotion_engine_registry_find(name);
313 if (!engine) 384 if (!engine)
314 ERR("Couldn't find requested engine: %s. Try fallback", name); 385 ERR("Couldn't find requested engine: %s. Try fallback", name);