Commit fd1220a2 authored by Sam Hocevar's avatar Sam Hocevar

 . removed a few useless malloc() and unused variables in the audio SDL stuff
 . prepared the work for built-in modules (not yet finished)
parent 627633ae
......@@ -38,31 +38,25 @@
* #define MODULE_VAR(blah) "VLC_MODULE_foo_blah"
*
* and, if BUILTIN is set, we will also need:
* #define InitModule foo_InitModule
* #define ActivateModule foo_ActivateModule
* #define DeactivateModule foo_DeactivateModule
* #define MODULE_FUNC( zog ) module_foo_zog
*
* this can't easily be done with the C preprocessor, thus a few ugly hacks.
*/
/* I can't believe I need to do this to change foo to "foo" */
#define UGLY_KLUDGE(z) NASTY_CROCK(z)
#define NASTY_CROCK(z) #z
/* And I need to do _this_ to change foo bar to foo_bar ! */
#define AWFUL_BRITTLE(y,z) CRUDE_HACK(y,z)
#define CRUDE_HACK(y,z) y##_##z
#define UGLY_KLUDGE( z ) NASTY_CROCK( z )
#define NASTY_CROCK( z ) #z
/* And I need to do _this_ to change foo bar to foo_inner_bar ! */
#define AWFUL_BRITTLE( y, z ) CRUDE_HACK( y, z )
#define CRUDE_HACK( y, z ) module_##y##_##z
/* Also, I need to do this to change blah to "VLC_MODULE_foo_blah" */
#define MODULE_STRING UGLY_KLUDGE(MODULE_NAME)
#define MODULE_VAR(z) "VLC_MODULE_" UGLY_KLUDGE(MODULE_NAME) "_" #z
#define MODULE_STRING UGLY_KLUDGE( MODULE_NAME )
#define MODULE_VAR( z ) "VLC_MODULE_" UGLY_KLUDGE( MODULE_NAME ) "_" #z
/* If the module is built-in, then we need to define foo_InitModule instead
* of InitModule. Same for Activate- and DeactivateModule. */
#ifdef BUILTIN
# define InitModule AWFUL_BRITTLE(MODULE_NAME,InitModule)
# define ActivateModule AWFUL_BRITTLE(MODULE_NAME,ActivateModule)
# define DeactivateModule AWFUL_BRITTLE(MODULE_NAME,DeactivateModule)
#endif
#define MODULE_FUNC( function ) AWFUL_BRITTLE( MODULE_NAME, function )
/*****************************************************************************
* Macros used to build the configuration structure.
......
This diff is collapsed.
......@@ -50,13 +50,74 @@
/*****************************************************************************
* Building configuration tree
*****************************************************************************/
MODULE_CONFIG_START
ADD_WINDOW( "Configuration for sdl module" )
ADD_COMMENT( "For now, the sdl module cannot be configured" )
ADD_WINDOW( "Configuration for SDL module" )
ADD_COMMENT( "For now, the SDL module cannot be configured" )
MODULE_CONFIG_END
/*****************************************************************************
* Capabilities defined in the other files.
******************************************************************************/
extern void aout_getfunctions( function_list_t * p_function_list );
/*****************************************************************************
* InitModule: get the module structure and configuration.
*****************************************************************************
* We have to fill psz_name, psz_longname and psz_version. These variables
* will be strdup()ed later by the main application because the module can
* be unloaded later to save memory, and we want to be able to access this
* data even after the module has been unloaded.
*****************************************************************************/
int InitModule( module_t * p_module )
{
p_module->psz_name = MODULE_STRING;
p_module->psz_longname = "Simple DirectMedia Layer module";
p_module->psz_version = VERSION;
p_module->i_capabilities = MODULE_CAPABILITY_NULL
| MODULE_CAPABILITY_AOUT;
return( 0 );
}
/*****************************************************************************
* ActivateModule: set the module to an usable state.
*****************************************************************************
* This function fills the capability functions and the configuration
* structure. Once ActivateModule() has been called, the i_usage can
* be set to 0 and calls to NeedModule() be made to increment it. To unload
* the module, one has to wait until i_usage == 0 and call DeactivateModule().
*****************************************************************************/
int ActivateModule( module_t * p_module )
{
p_module->p_functions = malloc( sizeof( module_functions_t ) );
if( p_module->p_functions == NULL )
{
return( -1 );
}
aout_getfunctions( &p_module->p_functions->aout );
p_module->p_config = p_config;
return( 0 );
}
/*****************************************************************************
* DeactivateModule: make sure the module can be unloaded.
*****************************************************************************
* This function must only be called when i_usage == 0. If it successfully
* returns, i_usage can be set to -1 and the module unloaded. Be careful to
* lock usage_lock during the whole process.
*****************************************************************************/
int DeactivateModule( module_t * p_module )
{
free( p_module->p_functions );
return( 0 );
}
/* old plugin API */
/*****************************************************************************
* Exported prototypes
......@@ -64,7 +125,6 @@ MODULE_CONFIG_END
static void vout_GetPlugin( p_vout_thread_t p_vout );
static void intf_GetPlugin( p_intf_thread_t p_intf );
/* Video output */
int vout_SDLCreate ( vout_thread_t *p_vout, char *psz_display,
int i_root_window, void *p_data );
......@@ -81,11 +141,6 @@ void intf_SDLDestroy ( p_intf_thread_t p_intf );
void intf_SDLManage ( p_intf_thread_t p_intf );
/*****************************************************************************
* * Capabilities defined in the other files.
******************************************************************************/
extern void aout_getfunctions( function_list_t * p_function_list );
/*****************************************************************************
* GetConfig: get the plugin structure and configuration
*****************************************************************************/
......@@ -140,64 +195,4 @@ static void intf_GetPlugin( p_intf_thread_t p_intf )
p_intf->p_sys_manage = intf_SDLManage;
}
/*****************************************************************************
* Audio stuff: All the new modules things
*****************************************************************************/
/*****************************************************************************
* InitModule: get the module structure and configuration.
*****************************************************************************
* We have to fill psz_name, psz_longname and psz_version. These variables
* will be strdup()ed later by the main application because the module can
* be unloaded later to save memory, and we want to be able to access this
* data even after the module has been unloaded.
*****************************************************************************/
int InitModule( module_t * p_module )
{
p_module->psz_name = MODULE_STRING;
p_module->psz_longname = "Linux SDL audio module";
p_module->psz_version = VERSION;
p_module->i_capabilities = MODULE_CAPABILITY_NULL
| MODULE_CAPABILITY_AOUT;
return( 0 );
}
/*****************************************************************************
* ActivateModule: set the module to an usable state.
*****************************************************************************
* This function fills the capability functions and the configuration
* structure. Once ActivateModule() has been called, the i_usage can
* be set to 0 and calls to NeedModule() be made to increment it. To unload
* the module, one has to wait until i_usage == 0 and call DeactivateModule().
*****************************************************************************/
int ActivateModule( module_t * p_module )
{
p_module->p_functions = malloc( sizeof( module_functions_t ) );
if( p_module->p_functions == NULL )
{
return( -1 );
}
aout_getfunctions( &p_module->p_functions->aout );
p_module->p_config = p_config;
return( 0 );
}
/*****************************************************************************
* DeactivateModule: make sure the module can be unloaded.
*****************************************************************************
* This function must only be called when i_usage == 0. If it successfully
* returns, i_usage can be set to -1 and the module unloaded. Be careful to
* lock usage_lock during the whole process.
*****************************************************************************/
int DeactivateModule( module_t * p_module )
{
free( p_module->p_functions );
return( 0 );
}
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