* Use ecore_plugin instead of dlfcn

* the modules names are now "xine" and "gstreamer" (it's useless to add
   the extension, as ecore_plugin do not need it). I'll fix eclair,
   etk_extra and ewl.
 * look for the modules in path that is pointed by the env variable
    EMOTION_MODULES_DIR first.
 * fix a leak in the gstreamer module
 * remove some trailing spaces


SVN revision: 32261
This commit is contained in:
doursse 2007-10-31 19:34:39 +00:00 committed by doursse
parent 5f684ac512
commit 4649e92bb8
7 changed files with 208 additions and 202 deletions

View File

@ -169,9 +169,6 @@ fi
AM_CONDITIONAL([BUILD_XINE_MODULE], [test "$HAVE_XINE" = yes]) AM_CONDITIONAL([BUILD_XINE_MODULE], [test "$HAVE_XINE" = yes])
AM_CONDITIONAL([BUILD_GSTREAMER_MODULE], [test "$HAVE_GSTREAMER" = yes]) AM_CONDITIONAL([BUILD_GSTREAMER_MODULE], [test "$HAVE_GSTREAMER" = yes])
AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl)
AC_SUBST(dlopen_libs)
AC_OUTPUT([ AC_OUTPUT([
Makefile Makefile
emotion.pc emotion.pc
@ -213,4 +210,3 @@ echo " binaries.......: $bindir"
echo " libraries......: $libdir" echo " libraries......: $libdir"
echo " headers........: $includedir" echo " headers........: $includedir"
echo echo

View File

@ -821,7 +821,7 @@ main(int argc, char **argv)
if (main_start(argc, argv) < 1) return -1; if (main_start(argc, argv) < 1) return -1;
bg_setup(); bg_setup();
module_filename = "emotion_decoder_xine.so"; module_filename = "xine";
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
@ -848,11 +848,11 @@ main(int argc, char **argv)
} }
else if (!strcmp(argv[i], "-xine")) else if (!strcmp(argv[i], "-xine"))
{ {
module_filename = "emotion_decoder_xine.so"; module_filename = "xine";
} }
else if (!strcmp(argv[i], "-gstreamer")) else if (!strcmp(argv[i], "-gstreamer"))
{ {
module_filename = "emotion_decoder_gstreamer.so"; module_filename = "gstreamer";
} }
else else
{ {

View File

@ -15,6 +15,6 @@ libemotion_la_SOURCES = \
emotion_smart.c \ emotion_smart.c \
emotion_private.h emotion_private.h
libemotion_la_LIBADD = @EVAS_LIBS@ @ECORE_LIBS@ @dlopen_libs@ libemotion_la_LIBADD = @EVAS_LIBS@ @ECORE_LIBS@
libemotion_la_DEPENDENCIES = $(top_builddir)/config.h libemotion_la_DEPENDENCIES = $(top_builddir)/config.h
libemotion_la_LDFLAGS = -version-info 0:1:0 libemotion_la_LDFLAGS = -version-info 0:1:0

View File

@ -4,6 +4,8 @@
#include <Evas.h> #include <Evas.h>
#include <Ecore.h> #include <Ecore.h>
#include <Ecore_Job.h> #include <Ecore_Job.h>
#include <Ecore_Data.h>
#include <Ecore_Str.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -120,7 +122,8 @@ struct _Emotion_Video_Module
int (*eject) (void *ef); int (*eject) (void *ef);
const char * (*meta_get) (void *ef, int meta); const char * (*meta_get) (void *ef, int meta);
void *handle; Ecore_Plugin *plugin;
int group_id;
}; };
EAPI void *_emotion_video_get(Evas_Object *obj); EAPI void *_emotion_video_get(Evas_Object *obj);

View File

@ -1,6 +1,5 @@
#include "Emotion.h" #include "Emotion.h"
#include "emotion_private.h" #include "emotion_private.h"
#include <dlfcn.h>
#define E_SMART_OBJ_GET(smart, o, type) \ #define E_SMART_OBJ_GET(smart, o, type) \
{ \ { \
@ -90,56 +89,62 @@ static Evas_Smart *smart = NULL;
static unsigned char static unsigned char
_emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module **mod, void **video) _emotion_module_open(const char *name, Evas_Object *obj, Emotion_Video_Module **mod, void **video)
{ {
void *handle; Ecore_Plugin *plugin;
char buf[4096]; int group_id;
char *tmp = NULL;
Smart_Data *sd; Smart_Data *sd;
E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0); E_SMART_OBJ_GET_RETURN(sd, obj, E_OBJ_NAME, 0);
snprintf(buf, sizeof(buf), "%s%s", PACKAGE_LIB_DIR"/emotion/", group_id = ecore_path_group_new("emotion_module");
name); tmp = getenv("EMOTION_MODULES_DIR");
handle = dlopen(buf, RTLD_LAZY); if (tmp)
if (handle) ecore_path_group_add(group_id, tmp);
ecore_path_group_add(group_id, PACKAGE_LIB_DIR"/emotion/");
plugin = ecore_plugin_load(group_id, name, NULL);
if (plugin)
{ {
unsigned char (*func_module_open)(Evas_Object *, Emotion_Video_Module **, void **, Emotion_Module_Options *); unsigned char (*func_module_open)(Evas_Object *, Emotion_Video_Module **, void **, Emotion_Module_Options *);
func_module_open = dlsym(handle, "module_open"); func_module_open = ecore_plugin_symbol_get(plugin, "module_open");
if (func_module_open) if (func_module_open)
{ {
if (func_module_open(obj, mod, video, &(sd->module_options))) if (func_module_open(obj, mod, video, &(sd->module_options)))
{ {
if (*mod) if (*mod)
{ {
(*mod)->handle = handle; (*mod)->plugin = plugin;
(*mod)->group_id = group_id;
return 1; return 1;
} }
} }
} }
dlclose(handle); ecore_plugin_unload(plugin);
} }
else else
{ printf ("Unable to load module %s\n", name);
char *err;
err = dlerror(); ecore_path_group_del(group_id);
printf ("No module. Error: %s\n", err);
}
return 0; return 0;
} }
static void static void
_emotion_module_close(Emotion_Video_Module *mod, void *video) _emotion_module_close(Emotion_Video_Module *mod, void *video)
{ {
void *handle; Ecore_Plugin *plugin;
void (*module_close) (Emotion_Video_Module *module, void *); void (*module_close) (Emotion_Video_Module *module, void *);
handle = mod->handle; plugin = mod->plugin;
module_close = dlsym(handle, "module_close"); module_close = ecore_plugin_symbol_get(mod->plugin, "module_close");
if ((module_close) && (video)) module_close(mod, video); if ((module_close) && (video)) module_close(mod, video);
/* FIXME: we can't go dlclosing here as a thread still may be running from /* FIXME: we can't go dlclosing here as a thread still may be running from
* the module - this in theory will leak- but it shouldnt be too bad and * the module - this in theory will leak- but it shouldnt be too bad and
* mean that once a module is dlopened() it cant be closed - its refcount * mean that once a module is dlopened() it cant be closed - its refcount
* will just keep going up * will just keep going up
*/ */
// dlclose(handle); /*
ecore_plugin_unload(plugin);
ecore_path_group_del(group_id);
*/
} }
/*******************************/ /*******************************/
@ -1181,6 +1186,7 @@ static void
_smart_del(Evas_Object * obj) _smart_del(Evas_Object * obj)
{ {
Smart_Data *sd; Smart_Data *sd;
sd = evas_object_smart_data_get(obj); sd = evas_object_smart_data_get(obj);
if (!sd) return; if (!sd) return;
if (sd->video) sd->module->file_close(sd->video); if (sd->video) sd->module->file_close(sd->video);

View File

@ -1,11 +1,11 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
if BUILD_XINE_MODULE if BUILD_XINE_MODULE
XINE_LIB_NAME=emotion_decoder_xine.la XINE_LIB_NAME = xine.la
endif endif
if BUILD_GSTREAMER_MODULE if BUILD_GSTREAMER_MODULE
GSTREAMER_LIB_NAME = emotion_decoder_gstreamer.la GSTREAMER_LIB_NAME = gstreamer.la
endif endif
#AUTOMAKE_OPTIONS = 1.4 foreign #AUTOMAKE_OPTIONS = 1.4 foreign
@ -22,24 +22,24 @@ pkgdir = $(libdir)/emotion
pkg_LTLIBRARIES = $(XINE_LIB_NAME) $(GSTREAMER_LIB_NAME) pkg_LTLIBRARIES = $(XINE_LIB_NAME) $(GSTREAMER_LIB_NAME)
if BUILD_XINE_MODULE if BUILD_XINE_MODULE
emotion_decoder_xine_la_SOURCES = \ xine_la_SOURCES = \
emotion_xine.c \ emotion_xine.c \
emotion_xine.h \ emotion_xine.h \
emotion_xine_vo_out.c emotion_xine_vo_out.c
emotion_decoder_xine_la_LIBADD = @EVAS_LIBS@ @ECORE_LIBS@ @XINE_LIBS@ $(top_builddir)/src/lib/libemotion.la -lpthread xine_la_LIBADD = @EVAS_LIBS@ @ECORE_LIBS@ @XINE_LIBS@ $(top_builddir)/src/lib/libemotion.la -lpthread
emotion_decoder_xine_la_LDFLAGS = -module -avoid-version \ xine_la_LDFLAGS = -module -avoid-version \
-L$(top_builddir)/src/lib -L$(top_builddir)/src/lib/.libs -L$(top_builddir)/src/lib -L$(top_builddir)/src/lib/.libs
emotion_decoder_xine_la_DEPENDENCIES = $(top_builddir)/config.h xine_la_DEPENDENCIES = $(top_builddir)/config.h
endif endif
if BUILD_GSTREAMER_MODULE if BUILD_GSTREAMER_MODULE
emotion_decoder_gstreamer_la_SOURCES = \ gstreamer_la_SOURCES = \
emotion_gstreamer.c \ emotion_gstreamer.c \
emotion_gstreamer.h \ emotion_gstreamer.h \
emotion_gstreamer_pipeline.c \ emotion_gstreamer_pipeline.c \
emotion_gstreamer_pipeline.h emotion_gstreamer_pipeline.h
emotion_decoder_gstreamer_la_LIBADD = @EVAS_LIBS@ @ECORE_LIBS@ @GST_LIBS@ $(top_builddir)/src/lib/libemotion.la gstreamer_la_LIBADD = @EVAS_LIBS@ @ECORE_LIBS@ @GST_LIBS@ $(top_builddir)/src/lib/libemotion.la
emotion_decoder_gstreamer_la_LDFLAGS = -module -avoid-version \ gstreamer_la_LDFLAGS = -module -avoid-version \
-L$(top_builddir)/src/lib -L$(top_builddir)/src/lib/.libs -L$(top_builddir)/src/lib -L$(top_builddir)/src/lib/.libs
emotion_decoder_gstreamer_la_DEPENDENCIES = $(top_builddir)/config.h gstreamer_la_DEPENDENCIES = $(top_builddir)/config.h
endif endif

View File

@ -328,6 +328,7 @@ em_shutdown(void *video)
ecore_list_destroy (ev->audio_sinks); ecore_list_destroy (ev->audio_sinks);
/* FIXME: and the evas object ? */ /* FIXME: and the evas object ? */
if (ev->obj_data) free(ev->obj_data);
ecore_main_fd_handler_del(ev->fd_ev_handler); ecore_main_fd_handler_del(ev->fd_ev_handler);
close(ev->fd_ev_write); close(ev->fd_ev_write);