]> git.sesse.net Git - vlc/commitdiff
. complete commenting of modules_core.h and small modifications
authorSam Hocevar <sam@videolan.org>
Wed, 10 Jan 2001 02:33:59 +0000 (02:33 +0000)
committerSam Hocevar <sam@videolan.org>
Wed, 10 Jan 2001 02:33:59 +0000 (02:33 +0000)
 . separated MODULE_CONFIG_START and ADD_WINDOW (Henri, beware)
 . fixed a very, very old bug that caused namespace collision between
   plugins (Henri, beware: call your aout_getplugin function like this,
   not alsa_aout_getplugin)
 . removed the Debian specific clean rules from the Makefile, since they
   are already handled by the debian/rules script.
 . tidied a few compilation rules (-lfoo should always be at the end)

Makefile.in
include/modules.h
include/modules_core.h
include/modules_inner.h
plugins/dsp/aout_dsp.c
plugins/dsp/dsp.c
plugins/esd/aout_esd.c
plugins/esd/esd.c
plugins/null/null.c
src/misc/modules.c
src/misc/plugins.c

index 4182d71628ea712777b350386a5b4652186b3d8f..9e2656c0ce9de34e040fe49f37ef3a07ddd913f3 100644 (file)
@@ -398,8 +398,6 @@ distclean: clean
        rm -f config.status config.cache config.log
        rm -f gmon.out core build-stamp
        rm -rf .dep
-       rm -rf debian/tmp debian/files debian/*.debhelper debian/*.substvars
-       find debian/* -type d -maxdepth 0 -name 'vlc-*' | xargs rm -rf
 
 install:
        mkdir -p $(prefix)/bin
@@ -480,8 +478,9 @@ $(PLUGIN_GLIDE): %.o: %.c
        $(CC) $(CFLAGS) $(PCFLAGS) -I/usr/include/glide -c -o $@ $<
 
 #
-# Real targets
+# Main application target
 #
+
 vlc: $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ)
 ifeq ($(SYS),beos)
        $(CC) $(CFLAGS) $(LCFLAGS) -Xlinker -soname=_APP_ -o $@ $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ)
@@ -491,61 +490,65 @@ else
        $(CC) $(CFLAGS) $(LCFLAGS) --export-dynamic @DYNAMIC_FLAG@ -o $@ $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ) 
 endif
 
+#
+# Plugin targets
+#
+
 lib/beos.so: $(PLUGIN_BEOS)
-       $(CC) $(CFLAGS) $(LCFLAGS) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
+       $(CC) $(PCFLAGS) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
 
 lib/esd.so: $(PLUGIN_ESD)
 ifneq (,$(findstring bsd,$(SYS)))
-       $(CC) -shared -lesd -o $@ $^ $(LCFLAGS) -lesd
+       $(CC) $(PCFLAGS) -shared -o $@ $^ -lesd
 else
-       $(CC) -shared -o $@ $^ $(LCFLAGS) -laudiofile -lesd
+       $(CC) $(PCFLAGS) -shared -o $@ $^ -laudiofile -lesd
 endif
 
 lib/dsp.so: $(PLUGIN_DSP)
-       $(CC) -shared -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^
 
 lib/alsa.so: $(PLUGIN_ALSA)
-       $(CC) -shared -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^
 
 lib/null.so: $(PLUGIN_NULL)
-       $(CC) -shared -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^
 
 lib/dummy.so: $(PLUGIN_DUMMY)
-       $(CC) -shared -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^
 
 lib/fb.so: $(PLUGIN_FB)
-       $(CC) -shared -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^
 
 lib/x11.so: $(PLUGIN_X11)
-       $(CC) -shared -L/usr/X11R6/lib -o $@ $^ $(LCFLAGS) -lX11 -lXext
+       $(CC) $(PCFLAGS) -shared -o $@ $^ -L/usr/X11R6/lib -lX11 -lXext
 
 lib/mga.so: $(PLUGIN_MGA)
-       $(CC) -shared -L/usr/X11R6/lib -o $@ $^ $(LCFLAGS) -lX11 -lXext
+       $(CC) $(PCFLAGS) -shared -o $@ $^ -L/usr/X11R6/lib -lX11 -lXext
 
 lib/gnome.so: $(PLUGIN_GNOME)
-       $(CC) -shared -o $@ $^ $(LCFLAGS) `gnome-config --libs gnomeui | sed 's,-rdynamic,,'`
+       $(CC) $(PCFLAGS) -shared -o $@ $^ `gnome-config --libs gnomeui | sed 's,-rdynamic,,'`
 
 lib/glide.so: $(PLUGIN_GLIDE)
-       $(CC) -shared $(LIB_GLIDE) -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^ $(LIB_GLIDE)
 
 lib/ggi.so: $(PLUGIN_GGI)
-       $(CC) -shared $(LIB_GGI) -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^ $(LIB_GGI)
 
 lib/sdl.so: $(PLUGIN_SDL)
-       $(CC) -shared $(LIB_SDL) -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^ $(LIB_SDL)
 
 lib/yuv.so: $(PLUGIN_YUV)
 ifeq ($(SYS),beos)
-       $(CC) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
+       $(CC) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
 else
-       $(CC) -shared -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^
 endif
 
 lib/yuvmmx.so: $(PLUGIN_YUVMMX)
 ifeq ($(SYS),beos)
-       $(CC) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
+       $(CC) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
 else
-       $(CC) -shared -o $@ $^ $(LCFLAGS)
+       $(CC) $(PCFLAGS) -shared -o $@ $^
 endif
 
 ################################################################################
index ab7aa8196ec14cf2a72deb3ec1e6f6b587aa6f11..3f69de74a0a8d006bb167b439a25ae96d2048c6c 100644 (file)
@@ -21,7 +21,7 @@
  *****************************************************************************/
 
 /* Number of tries before we unload an unused module */
-#define MODULE_HIDE_DELAY 50
+#define MODULE_HIDE_DELAY 100
 
 /* The module handle type. */
 #ifdef SYS_BEOS
@@ -100,20 +100,21 @@ typedef struct module_functions_s * p_module_functions_t;
  *****************************************************************************/
 
 /* Mandatory first and last parts of the structure */
-#define MODULE_CONFIG_ITEM_START       0x01    /* The main window */
-#define MODULE_CONFIG_ITEM_END         0x00    /* End of the window */
+#define MODULE_CONFIG_ITEM_START       0xdead  /* The main window */
+#define MODULE_CONFIG_ITEM_END         0xbeef  /* End of the window */
 
 /* Configuration widgets */
-#define MODULE_CONFIG_ITEM_PANE        0x02    /* A notebook pane */
-#define MODULE_CONFIG_ITEM_FRAME       0x03    /* A frame */
-#define MODULE_CONFIG_ITEM_COMMENT     0x04    /* A comment text */
-#define MODULE_CONFIG_ITEM_STRING      0x05    /* A string */
-#define MODULE_CONFIG_ITEM_FILE        0x06    /* A file selector */
-#define MODULE_CONFIG_ITEM_CHECK       0x07    /* A checkbox */
-#define MODULE_CONFIG_ITEM_CHOOSE      0x08    /* A choose box */
-#define MODULE_CONFIG_ITEM_RADIO       0x09    /* A radio box */
-#define MODULE_CONFIG_ITEM_SCALE       0x0a    /* A horizontal ruler */
-#define MODULE_CONFIG_ITEM_SPIN        0x0b    /* A numerical selector */
+#define MODULE_CONFIG_ITEM_WINDOW      0x0001  /* The main window */
+#define MODULE_CONFIG_ITEM_PANE        0x0002  /* A notebook pane */
+#define MODULE_CONFIG_ITEM_FRAME       0x0003  /* A frame */
+#define MODULE_CONFIG_ITEM_COMMENT     0x0004  /* A comment text */
+#define MODULE_CONFIG_ITEM_STRING      0x0005  /* A string */
+#define MODULE_CONFIG_ITEM_FILE        0x0006  /* A file selector */
+#define MODULE_CONFIG_ITEM_CHECK       0x0007  /* A checkbox */
+#define MODULE_CONFIG_ITEM_CHOOSE      0x0008  /* A choose box */
+#define MODULE_CONFIG_ITEM_RADIO       0x0009  /* A radio box */
+#define MODULE_CONFIG_ITEM_SCALE       0x000a  /* A horizontal ruler */
+#define MODULE_CONFIG_ITEM_SPIN        0x000b  /* A numerical selector */
 
 typedef struct module_config_s
 {
index bd4e93fff82ddaeeb1fbbd77ffe37dbab0e2eb39..5f7e936a243f29176688f69d1d18970c13641428 100644 (file)
  * Inline functions for handling dynamic modules
  *****************************************************************************/
 
-/* Function to load a dynamic module, returns 0 if successful. */
+/*****************************************************************************
+ * module_load: load a dynamic library
+ *****************************************************************************
+ * This function loads a dynamically linked library using a system dependant
+ * method, and returns a non-zero value on error, zero otherwise.
+ *****************************************************************************/
 static __inline__ int
 module_load( char * psz_filename, module_handle_t * handle )
 {
 #ifdef SYS_BEOS
     *handle = load_add_on( psz_filename );
-    return( *handle >= 0 );
+    return( *handle < 0 );
 #else
-    *handle = dlopen( psz_filename, RTLD_NOW | RTLD_GLOBAL );
-    return( *handle != NULL );
+    /* Do not open modules with RTLD_GLOBAL, or we are going to get namespace
+     * collisions when two modules have common public symbols */
+    *handle = dlopen( psz_filename, RTLD_NOW );
+    return( *handle == NULL );
 #endif
 }
 
-/* Unload a dynamic module. */
+/*****************************************************************************
+ * module_unload: unload a dynamic library
+ *****************************************************************************
+ * This function unloads a previously opened dynamically linked library
+ * using a system dependant method. No return value is taken in consideration,
+ * since some libraries sometimes refuse to close properly.
+ *****************************************************************************/
 static __inline__ void
 module_unload( module_handle_t handle )
 {
@@ -49,7 +62,15 @@ module_unload( module_handle_t handle )
     return;
 }
 
-/* Get a given symbol from a module. */
+/*****************************************************************************
+ * module_getsymbol: get a symbol from a dynamic library
+ *****************************************************************************
+ * This function queries a loaded library for a symbol specified in a
+ * string, and returns a pointer to it.
+ * FIXME: under Unix we should maybe check for dlerror() instead of the
+ * return value of dlsym, since we could have loaded a symbol really set
+ * to NULL (quite unlikely, though).
+ *****************************************************************************/
 static __inline__ void *
 module_getsymbol( module_handle_t handle, char * psz_function )
 {
@@ -62,8 +83,14 @@ module_getsymbol( module_handle_t handle, char * psz_function )
 #endif
 }
 
-/* Wrapper to dlerror() for systems that don't have it. */
-static __inline__ char *
+/*****************************************************************************
+ * module_error: wrapper for dlerror()
+ *****************************************************************************
+ * This function returns the error message of the last module operation. It
+ * returns the string "failed" on systems which do not have the dlerror()
+ * function.
+ *****************************************************************************/
+static __inline__ const char *
 module_error( void )
 {
 #ifdef SYS_BEOS
index a966569bcce3e3348f5a44f0343a1abd29ae844c..00dabcac1bf7207c79a4b4b41593541a5071376e 100644 (file)
 /*****************************************************************************
  * Macros used to build the configuration structure.
  *****************************************************************************/
-#define MODULE_CONFIG_START( text ) \
+#define MODULE_CONFIG_START \
 static module_config_t p_config[] = { \
-    { MODULE_CONFIG_ITEM_START, text, NULL, NULL, NULL },
+    { MODULE_CONFIG_ITEM_START, NULL, NULL, NULL, NULL },
 
-#define MODULE_CONFIG_END   \
+#define MODULE_CONFIG_END \
     { MODULE_CONFIG_ITEM_END, NULL, NULL, NULL, NULL } \
 };
 
+#define ADD_WINDOW( text ) \
+    { MODULE_CONFIG_ITEM_WINDOW, text, NULL, NULL, NULL },
 #define ADD_FRAME( text ) \
     { MODULE_CONFIG_ITEM_FRAME, text, NULL, NULL, NULL },
 #define ADD_PANE( text ) \
index 5e25f58f43868d32316af938e4b9c30e732ec957..4569523f8164cf93dce918245b4aa4d212865c33 100644 (file)
@@ -90,7 +90,7 @@ static void    aout_Close       ( aout_thread_t *p_aout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void dsp_aout_getfunctions( function_list_t * p_function_list )
+void aout_getfunctions( function_list_t * p_function_list )
 {
     p_function_list->p_probe = aout_Probe;
     p_function_list->functions.aout.p_open = aout_Open;
index 709a9fcaf11465afb2d545c1c4ceab2a9ae759cb..2db3d0d5ec4a167f0ad92bb3298b396c2365653c 100644 (file)
@@ -43,7 +43,8 @@
 /*****************************************************************************
  * Build configuration tree.
  *****************************************************************************/
-MODULE_CONFIG_START( "Configuration for dsp module" )
+MODULE_CONFIG_START
+ADD_WINDOW( "Configuration for dsp module" )
     ADD_FRAME( "OSS Device" )
         ADD_FILE( "Device name: ", MODULE_VAR(device), NULL )
 MODULE_CONFIG_END
@@ -51,7 +52,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-void dsp_aout_getfunctions( function_list_t * p_function_list );
+extern void aout_getfunctions( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -89,7 +90,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    dsp_aout_getfunctions( &p_module->p_functions->aout );
+    aout_getfunctions( &p_module->p_functions->aout );
 
     p_module->p_config = p_config;
 
index 10255e3e2f24605c003df7020f4f797399a8f972..b8407caf6a3c51ac1f243d866e667f2e0c1e05ee 100644 (file)
@@ -80,7 +80,7 @@ static void    aout_Close       ( aout_thread_t *p_aout );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void esd_aout_getfunctions( function_list_t * p_function_list )
+void aout_getfunctions( function_list_t * p_function_list )
 {
     p_function_list->p_probe = aout_Probe;
     p_function_list->functions.aout.p_open = aout_Open;
index 2cafb04d25b98a859d9dc2f170e6477a199673b3..f843ab1e54bd7467760404e5bdb22d0cc565b3f1 100644 (file)
@@ -42,7 +42,8 @@
 /*****************************************************************************
  * Build configuration tree.
  *****************************************************************************/
-MODULE_CONFIG_START( "Configuration for esd module" )
+MODULE_CONFIG_START
+ADD_WINDOW( "Configuration for esd module" )
     ADD_FRAME( "EsounD" )
         ADD_COMMENT( "This module does not need configuration" )
 MODULE_CONFIG_END
@@ -50,7 +51,7 @@ MODULE_CONFIG_END
 /*****************************************************************************
  * Capabilities defined in the other files.
  *****************************************************************************/
-void esd_aout_getfunctions( function_list_t * p_function_list );
+extern void aout_getfunctions( function_list_t * p_function_list );
 
 /*****************************************************************************
  * InitModule: get the module structure and configuration.
@@ -88,7 +89,7 @@ int ActivateModule( module_t * p_module )
         return( -1 );
     }
 
-    esd_aout_getfunctions( &p_module->p_functions->aout );
+    aout_getfunctions( &p_module->p_functions->aout );
 
     p_module->p_config = p_config;
 
index 271b2c13a4668a19d76f782410141e011c88fe5e..f4078a4638236248dd0fc79d1eacd01751ad870f 100644 (file)
@@ -42,7 +42,8 @@
 /*****************************************************************************
  * Build configuration tree.
  *****************************************************************************/
-MODULE_CONFIG_START( "Configuration for null module" )
+MODULE_CONFIG_START
+ADD_WINDOW( "Configuration for null module" )
     ADD_PANE( "First pane" )
         ADD_FRAME( "First frame" )
             ADD_COMMENT( "You can put whatever you want here." )
index 65bc8631c407e78ccb5770e88f16e317dde71c6f..bfbf2c91cb2aec31a52d69d362176a0def7f1168 100644 (file)
@@ -350,10 +350,10 @@ static int AllocateDynModule( module_bank_t * p_bank, char * psz_filename )
     module_handle_t handle;
 
     /* Try to dynamically load the module. */
-    if( module_load( psz_filename, &handle ) )
+    if( module_load( psz_filename, &handle ) )
     {
         /* The dynamic module couldn't be opened */
-        intf_DbgMsg( "module error: cannot open %s (%s)",
+        intf_DbgMsg( "module warning: cannot open %s (%s)",
                      psz_filename, module_error() );
         return( -1 );
     }
@@ -603,7 +603,7 @@ static int LockModule( module_t * p_module )
     }
 
     /* i_usage == -1, which means that the module isn't in memory */
-    if( module_load( p_module->psz_filename, &p_module->handle ) )
+    if( module_load( p_module->psz_filename, &p_module->handle ) )
     {
         /* The dynamic module couldn't be opened */
         intf_ErrMsg( "module error: cannot open %s (%s)",
index 459eac9301f2949979f98bf44cfb48c64889df57..bef0f3ac581677e2f243f1791d53194661a46ed3 100644 (file)
@@ -176,7 +176,7 @@ char * TestPlugin ( plugin_id_t *p_plugin_id, char * psz_name )
         }
         close( i_fd );
         
-        *p_plugin_id = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL );
+        *p_plugin_id = dlopen( psz_plugin, RTLD_NOW );
 #endif
 
 #ifdef SYS_BEOS