From edf90cc827fdbfd9549cd9e1f62eab31ade1d3d9 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 30 Dec 2009 12:54:06 +0000 Subject: [PATCH] * emotion: Add backend autodetection ability (you can pass NULL, and have some good hope for a result now :-) ) SVN revision: 44784 --- legacy/emotion/src/bin/emotion_test_main.c | 4 ++++ legacy/emotion/src/lib/emotion_smart.c | 20 +++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/legacy/emotion/src/bin/emotion_test_main.c b/legacy/emotion/src/bin/emotion_test_main.c index 92de9d1a96..edccfe6569 100644 --- a/legacy/emotion/src/bin/emotion_test_main.c +++ b/legacy/emotion/src/bin/emotion_test_main.c @@ -866,6 +866,10 @@ main(int argc, char **argv) else if (!strcmp(argv[i], "-xr")) { } + else if (!strcmp(argv[i], "-auto")) + { + module_filename = NULL; + } else if (!strcmp(argv[i], "-xine")) { module_filename = "xine"; diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c index c9ceca373e..e3c54b417f 100644 --- a/legacy/emotion/src/lib/emotion_smart.c +++ b/legacy/emotion/src/lib/emotion_smart.c @@ -88,13 +88,17 @@ static Evas_Smart *smart = NULL; static Eina_Hash *_backends = NULL; static Eina_Array *_modules = NULL; +static const char *_backend_priority[] = { + "xine", + "gstreamer", + "vlc" +}; + EAPI Eina_Bool _emotion_module_register(const char *name, Emotion_Module_Open open, Emotion_Module_Close close) { Eina_Emotion_Plugins *plugin; - fprintf(stderr, "registering: %s\n", name); - plugin = malloc(sizeof (Eina_Emotion_Plugins)); if (!plugin) return EINA_FALSE; @@ -107,7 +111,6 @@ EAPI Eina_Bool EAPI Eina_Bool _emotion_module_unregister(const char *name) { - fprintf(stderr, "unregistering: %s\n", name); return eina_hash_del(_backends, name, NULL); } @@ -116,6 +119,7 @@ _emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module ** { Eina_Emotion_Plugins *plugin; Smart_Data *sd; + int index = 0; E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0); if (!_backends) @@ -125,9 +129,16 @@ _emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module ** } /* FIXME: Always look for a working backend. */ + retry: + if (name == NULL || index > 0) + name = _backend_priority[index++]; + plugin = eina_hash_find(_backends, name); if (!plugin) { + if (index != 0 && index < (sizeof (_backend_priority) / sizeof (char*))) + goto retry; + fprintf(stderr, "No backend loaded\n"); return EINA_FALSE; } @@ -141,6 +152,9 @@ _emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module ** } } + if (index != 0 && index < (sizeof (_backend_priority) / sizeof (char*))) + goto retry; + fprintf (stderr, "Unable to load module %s\n", name); return EINA_FALSE;