Commit 9f553534 authored by Sam Hocevar's avatar Sam Hocevar

 . complete commenting of modules_core.h and small modifications
 . 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)
parent 9451c9b9
...@@ -398,8 +398,6 @@ distclean: clean ...@@ -398,8 +398,6 @@ distclean: clean
rm -f config.status config.cache config.log rm -f config.status config.cache config.log
rm -f gmon.out core build-stamp rm -f gmon.out core build-stamp
rm -rf .dep 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: install:
mkdir -p $(prefix)/bin mkdir -p $(prefix)/bin
...@@ -480,8 +478,9 @@ $(PLUGIN_GLIDE): %.o: %.c ...@@ -480,8 +478,9 @@ $(PLUGIN_GLIDE): %.o: %.c
$(CC) $(CFLAGS) $(PCFLAGS) -I/usr/include/glide -c -o $@ $< $(CC) $(CFLAGS) $(PCFLAGS) -I/usr/include/glide -c -o $@ $<
# #
# Real targets # Main application target
# #
vlc: $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ) vlc: $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ)
ifeq ($(SYS),beos) ifeq ($(SYS),beos)
$(CC) $(CFLAGS) $(LCFLAGS) -Xlinker -soname=_APP_ -o $@ $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ) $(CC) $(CFLAGS) $(LCFLAGS) -Xlinker -soname=_APP_ -o $@ $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ)
...@@ -491,61 +490,65 @@ else ...@@ -491,61 +490,65 @@ else
$(CC) $(CFLAGS) $(LCFLAGS) --export-dynamic @DYNAMIC_FLAG@ -o $@ $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ) $(CC) $(CFLAGS) $(LCFLAGS) --export-dynamic @DYNAMIC_FLAG@ -o $@ $(C_OBJ) $(CPP_OBJ) $(ASM_OBJ)
endif endif
#
# Plugin targets
#
lib/beos.so: $(PLUGIN_BEOS) 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) lib/esd.so: $(PLUGIN_ESD)
ifneq (,$(findstring bsd,$(SYS))) ifneq (,$(findstring bsd,$(SYS)))
$(CC) -shared -lesd -o $@ $^ $(LCFLAGS) -lesd $(CC) $(PCFLAGS) -shared -o $@ $^ -lesd
else else
$(CC) -shared -o $@ $^ $(LCFLAGS) -laudiofile -lesd $(CC) $(PCFLAGS) -shared -o $@ $^ -laudiofile -lesd
endif endif
lib/dsp.so: $(PLUGIN_DSP) lib/dsp.so: $(PLUGIN_DSP)
$(CC) -shared -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^
lib/alsa.so: $(PLUGIN_ALSA) lib/alsa.so: $(PLUGIN_ALSA)
$(CC) -shared -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^
lib/null.so: $(PLUGIN_NULL) lib/null.so: $(PLUGIN_NULL)
$(CC) -shared -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^
lib/dummy.so: $(PLUGIN_DUMMY) lib/dummy.so: $(PLUGIN_DUMMY)
$(CC) -shared -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^
lib/fb.so: $(PLUGIN_FB) lib/fb.so: $(PLUGIN_FB)
$(CC) -shared -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^
lib/x11.so: $(PLUGIN_X11) 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) 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) 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) lib/glide.so: $(PLUGIN_GLIDE)
$(CC) -shared $(LIB_GLIDE) -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^ $(LIB_GLIDE)
lib/ggi.so: $(PLUGIN_GGI) lib/ggi.so: $(PLUGIN_GGI)
$(CC) -shared $(LIB_GGI) -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^ $(LIB_GGI)
lib/sdl.so: $(PLUGIN_SDL) lib/sdl.so: $(PLUGIN_SDL)
$(CC) -shared $(LIB_SDL) -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^ $(LIB_SDL)
lib/yuv.so: $(PLUGIN_YUV) lib/yuv.so: $(PLUGIN_YUV)
ifeq ($(SYS),beos) ifeq ($(SYS),beos)
$(CC) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_ $(CC) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
else else
$(CC) -shared -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^
endif endif
lib/yuvmmx.so: $(PLUGIN_YUVMMX) lib/yuvmmx.so: $(PLUGIN_YUVMMX)
ifeq ($(SYS),beos) ifeq ($(SYS),beos)
$(CC) $(CFLAGS) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_ $(CC) -nostart -Xlinker -soname=$@ -o $@ $^ plugins/_APP_
else else
$(CC) -shared -o $@ $^ $(LCFLAGS) $(CC) $(PCFLAGS) -shared -o $@ $^
endif endif
################################################################################ ################################################################################
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
*****************************************************************************/ *****************************************************************************/
/* Number of tries before we unload an unused module */ /* Number of tries before we unload an unused module */
#define MODULE_HIDE_DELAY 50 #define MODULE_HIDE_DELAY 100
/* The module handle type. */ /* The module handle type. */
#ifdef SYS_BEOS #ifdef SYS_BEOS
...@@ -100,20 +100,21 @@ typedef struct module_functions_s * p_module_functions_t; ...@@ -100,20 +100,21 @@ typedef struct module_functions_s * p_module_functions_t;
*****************************************************************************/ *****************************************************************************/
/* Mandatory first and last parts of the structure */ /* Mandatory first and last parts of the structure */
#define MODULE_CONFIG_ITEM_START 0x01 /* The main window */ #define MODULE_CONFIG_ITEM_START 0xdead /* The main window */
#define MODULE_CONFIG_ITEM_END 0x00 /* End of the window */ #define MODULE_CONFIG_ITEM_END 0xbeef /* End of the window */
/* Configuration widgets */ /* Configuration widgets */
#define MODULE_CONFIG_ITEM_PANE 0x02 /* A notebook pane */ #define MODULE_CONFIG_ITEM_WINDOW 0x0001 /* The main window */
#define MODULE_CONFIG_ITEM_FRAME 0x03 /* A frame */ #define MODULE_CONFIG_ITEM_PANE 0x0002 /* A notebook pane */
#define MODULE_CONFIG_ITEM_COMMENT 0x04 /* A comment text */ #define MODULE_CONFIG_ITEM_FRAME 0x0003 /* A frame */
#define MODULE_CONFIG_ITEM_STRING 0x05 /* A string */ #define MODULE_CONFIG_ITEM_COMMENT 0x0004 /* A comment text */
#define MODULE_CONFIG_ITEM_FILE 0x06 /* A file selector */ #define MODULE_CONFIG_ITEM_STRING 0x0005 /* A string */
#define MODULE_CONFIG_ITEM_CHECK 0x07 /* A checkbox */ #define MODULE_CONFIG_ITEM_FILE 0x0006 /* A file selector */
#define MODULE_CONFIG_ITEM_CHOOSE 0x08 /* A choose box */ #define MODULE_CONFIG_ITEM_CHECK 0x0007 /* A checkbox */
#define MODULE_CONFIG_ITEM_RADIO 0x09 /* A radio box */ #define MODULE_CONFIG_ITEM_CHOOSE 0x0008 /* A choose box */
#define MODULE_CONFIG_ITEM_SCALE 0x0a /* A horizontal ruler */ #define MODULE_CONFIG_ITEM_RADIO 0x0009 /* A radio box */
#define MODULE_CONFIG_ITEM_SPIN 0x0b /* A numerical selector */ #define MODULE_CONFIG_ITEM_SCALE 0x000a /* A horizontal ruler */
#define MODULE_CONFIG_ITEM_SPIN 0x000b /* A numerical selector */
typedef struct module_config_s typedef struct module_config_s
{ {
......
...@@ -24,20 +24,33 @@ ...@@ -24,20 +24,33 @@
* Inline functions for handling dynamic modules * 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 static __inline__ int
module_load( char * psz_filename, module_handle_t * handle ) module_load( char * psz_filename, module_handle_t * handle )
{ {
#ifdef SYS_BEOS #ifdef SYS_BEOS
*handle = load_add_on( psz_filename ); *handle = load_add_on( psz_filename );
return( *handle >= 0 ); return( *handle < 0 );
#else #else
*handle = dlopen( psz_filename, RTLD_NOW | RTLD_GLOBAL ); /* Do not open modules with RTLD_GLOBAL, or we are going to get namespace
return( *handle != NULL ); * collisions when two modules have common public symbols */
*handle = dlopen( psz_filename, RTLD_NOW );
return( *handle == NULL );
#endif #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 static __inline__ void
module_unload( module_handle_t handle ) module_unload( module_handle_t handle )
{ {
...@@ -49,7 +62,15 @@ module_unload( module_handle_t handle ) ...@@ -49,7 +62,15 @@ module_unload( module_handle_t handle )
return; 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 * static __inline__ void *
module_getsymbol( module_handle_t handle, char * psz_function ) module_getsymbol( module_handle_t handle, char * psz_function )
{ {
...@@ -62,8 +83,14 @@ module_getsymbol( module_handle_t handle, char * psz_function ) ...@@ -62,8 +83,14 @@ module_getsymbol( module_handle_t handle, char * psz_function )
#endif #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 ) module_error( void )
{ {
#ifdef SYS_BEOS #ifdef SYS_BEOS
......
...@@ -67,14 +67,16 @@ ...@@ -67,14 +67,16 @@
/***************************************************************************** /*****************************************************************************
* Macros used to build the configuration structure. * Macros used to build the configuration structure.
*****************************************************************************/ *****************************************************************************/
#define MODULE_CONFIG_START( text ) \ #define MODULE_CONFIG_START \
static module_config_t p_config[] = { \ 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 } \ { MODULE_CONFIG_ITEM_END, NULL, NULL, NULL, NULL } \
}; };
#define ADD_WINDOW( text ) \
{ MODULE_CONFIG_ITEM_WINDOW, text, NULL, NULL, NULL },
#define ADD_FRAME( text ) \ #define ADD_FRAME( text ) \
{ MODULE_CONFIG_ITEM_FRAME, text, NULL, NULL, NULL }, { MODULE_CONFIG_ITEM_FRAME, text, NULL, NULL, NULL },
#define ADD_PANE( text ) \ #define ADD_PANE( text ) \
......
...@@ -90,7 +90,7 @@ static void aout_Close ( aout_thread_t *p_aout ); ...@@ -90,7 +90,7 @@ static void aout_Close ( aout_thread_t *p_aout );
* Functions exported as capabilities. They are declared as static so that * Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much. * 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->p_probe = aout_Probe;
p_function_list->functions.aout.p_open = aout_Open; p_function_list->functions.aout.p_open = aout_Open;
......
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
/***************************************************************************** /*****************************************************************************
* Build configuration tree. * Build configuration tree.
*****************************************************************************/ *****************************************************************************/
MODULE_CONFIG_START( "Configuration for dsp module" ) MODULE_CONFIG_START
ADD_WINDOW( "Configuration for dsp module" )
ADD_FRAME( "OSS Device" ) ADD_FRAME( "OSS Device" )
ADD_FILE( "Device name: ", MODULE_VAR(device), NULL ) ADD_FILE( "Device name: ", MODULE_VAR(device), NULL )
MODULE_CONFIG_END MODULE_CONFIG_END
...@@ -51,7 +52,7 @@ MODULE_CONFIG_END ...@@ -51,7 +52,7 @@ MODULE_CONFIG_END
/***************************************************************************** /*****************************************************************************
* Capabilities defined in the other files. * 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. * InitModule: get the module structure and configuration.
...@@ -89,7 +90,7 @@ int ActivateModule( module_t * p_module ) ...@@ -89,7 +90,7 @@ int ActivateModule( module_t * p_module )
return( -1 ); return( -1 );
} }
dsp_aout_getfunctions( &p_module->p_functions->aout ); aout_getfunctions( &p_module->p_functions->aout );
p_module->p_config = p_config; p_module->p_config = p_config;
......
...@@ -80,7 +80,7 @@ static void aout_Close ( aout_thread_t *p_aout ); ...@@ -80,7 +80,7 @@ static void aout_Close ( aout_thread_t *p_aout );
* Functions exported as capabilities. They are declared as static so that * Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much. * 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->p_probe = aout_Probe;
p_function_list->functions.aout.p_open = aout_Open; p_function_list->functions.aout.p_open = aout_Open;
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
/***************************************************************************** /*****************************************************************************
* Build configuration tree. * Build configuration tree.
*****************************************************************************/ *****************************************************************************/
MODULE_CONFIG_START( "Configuration for esd module" ) MODULE_CONFIG_START
ADD_WINDOW( "Configuration for esd module" )
ADD_FRAME( "EsounD" ) ADD_FRAME( "EsounD" )
ADD_COMMENT( "This module does not need configuration" ) ADD_COMMENT( "This module does not need configuration" )
MODULE_CONFIG_END MODULE_CONFIG_END
...@@ -50,7 +51,7 @@ MODULE_CONFIG_END ...@@ -50,7 +51,7 @@ MODULE_CONFIG_END
/***************************************************************************** /*****************************************************************************
* Capabilities defined in the other files. * 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. * InitModule: get the module structure and configuration.
...@@ -88,7 +89,7 @@ int ActivateModule( module_t * p_module ) ...@@ -88,7 +89,7 @@ int ActivateModule( module_t * p_module )
return( -1 ); return( -1 );
} }
esd_aout_getfunctions( &p_module->p_functions->aout ); aout_getfunctions( &p_module->p_functions->aout );
p_module->p_config = p_config; p_module->p_config = p_config;
......
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
/***************************************************************************** /*****************************************************************************
* Build configuration tree. * Build configuration tree.
*****************************************************************************/ *****************************************************************************/
MODULE_CONFIG_START( "Configuration for null module" ) MODULE_CONFIG_START
ADD_WINDOW( "Configuration for null module" )
ADD_PANE( "First pane" ) ADD_PANE( "First pane" )
ADD_FRAME( "First frame" ) ADD_FRAME( "First frame" )
ADD_COMMENT( "You can put whatever you want here." ) ADD_COMMENT( "You can put whatever you want here." )
......
...@@ -350,10 +350,10 @@ static int AllocateDynModule( module_bank_t * p_bank, char * psz_filename ) ...@@ -350,10 +350,10 @@ static int AllocateDynModule( module_bank_t * p_bank, char * psz_filename )
module_handle_t handle; module_handle_t handle;
/* Try to dynamically load the module. */ /* 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 */ /* 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() ); psz_filename, module_error() );
return( -1 ); return( -1 );
} }
...@@ -603,7 +603,7 @@ static int LockModule( module_t * p_module ) ...@@ -603,7 +603,7 @@ static int LockModule( module_t * p_module )
} }
/* i_usage == -1, which means that the module isn't in memory */ /* 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 */ /* The dynamic module couldn't be opened */
intf_ErrMsg( "module error: cannot open %s (%s)", intf_ErrMsg( "module error: cannot open %s (%s)",
......
...@@ -176,7 +176,7 @@ char * TestPlugin ( plugin_id_t *p_plugin_id, char * psz_name ) ...@@ -176,7 +176,7 @@ char * TestPlugin ( plugin_id_t *p_plugin_id, char * psz_name )
} }
close( i_fd ); close( i_fd );
*p_plugin_id = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL ); *p_plugin_id = dlopen( psz_plugin, RTLD_NOW );
#endif #endif
#ifdef SYS_BEOS #ifdef SYS_BEOS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment