options callbacks.
They don't take any argument for the moment, but this will change when
I'm finished with my other vlc changes. There is a little problem: the
Gtk+ interface keeps calling Put***Variable each time we click on "Apply"
or "Save". I think it should only call it once. Is there a way to fix
this? Gildas? lool? :-)
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: common.h,v 1.102 2002/04/27 22:11:22 gbazin Exp $
+ * $Id: common.h,v 1.103 2002/05/03 20:49:30 sam Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
int ( * config_SaveConfigFile ) ( const char * );
struct module_config_s * ( * config_FindConfig ) ( const char * );
struct module_config_s * ( * config_Duplicate ) ( struct module_config_s* );
+ void ( * config_SetCallbacks ) ( struct module_config_s *,
+ struct module_config_s * );
+ void ( * config_UnsetCallbacks ) ( struct module_config_s * );
struct intf_subscription_s * ( * intf_MsgSub ) ( void );
void ( * intf_MsgUnsub ) ( struct intf_subscription_s * );
* It includes functions allowing to declare, get or set configuration options.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: configuration.h,v 1.9 2002/04/24 00:36:24 sam Exp $
+ * $Id: configuration.h,v 1.10 2002/05/03 20:49:30 sam Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
void config_PutFloatVariable( const char *psz_name, float f_value );
void config_PutPszVariable( const char *psz_name, char *psz_value );
-int config_LoadConfigFile( const char *psz_module_name );
-int config_SaveConfigFile( const char *psz_module_name );
-module_config_t *config_FindConfig( const char *psz_name );
-module_config_t *config_Duplicate ( module_config_t * );
-char *config_GetHomeDir( void );
-int config_LoadCmdLine( int *pi_argc, char *ppsz_argv[],
- boolean_t b_ignore_errors );
+int config_LoadConfigFile( const char *psz_module_name );
+int config_SaveConfigFile( const char *psz_module_name );
+char * config_GetHomeDir( void );
+int config_LoadCmdLine( int *pi_argc, char *ppsz_argv[],
+ boolean_t b_ignore_errors );
+
+module_config_t *config_Duplicate ( module_config_t * );
+module_config_t *config_FindConfig ( const char * );
+void config_SetCallbacks ( module_config_t *, module_config_t * );
+void config_UnsetCallbacks( module_config_t * );
#else
# define config_GetIntVariable p_symbols->config_GetIntVariable
# define config_PutFloatVariable p_symbols->config_PutFloatVariable
# define config_GetPszVariable p_symbols->config_GetPszVariable
# define config_PutPszVariable p_symbols->config_PutPszVariable
-# define config_Duplicate p_symbols->config_Duplicate
-# define config_FindConfig p_symbols->config_FindConfig
# define config_LoadConfigFile p_symbols->config_LoadConfigFile
# define config_SaveConfigFile p_symbols->config_SaveConfigFile
+# define config_Duplicate p_symbols->config_Duplicate
+# define config_FindConfig p_symbols->config_FindConfig
+# define config_SetCallbacks p_symbols->config_SetCallbacks
+# define config_UnsetCallbacks p_symbols->config_UnsetCallbacks
#endif
/*****************************************************************************
* modules_inner.h : Macros used from within a module.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: modules_inner.h,v 1.17 2002/04/28 17:52:37 sam Exp $
+ * $Id: modules_inner.h,v 1.18 2002/05/03 20:49:30 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
p_module->psz_program = NULL; \
p_module->pp_shortcuts[ 0 ] = MODULE_STRING; \
p_module->i_capabilities = 0; \
- p_module->i_cpu_capabilities = 0;
+ p_module->i_cpu_capabilities = 0; \
+ do {
#define MODULE_INIT_STOP \
+ } while( 0 ); \
STORE_SYMBOLS; \
p_module->pp_shortcuts[ i_shortcut ] = NULL; \
p_module->i_config_items = 0; \
#define MODULE_ACTIVATE_START \
int __VLC_SYMBOL( ActivateModule ) ( module_t *p_module ) \
{ \
+ config_SetCallbacks( p_module->p_config, p_config ); \
p_module->p_functions = \
( module_functions_t * )malloc( sizeof( module_functions_t ) ); \
if( p_module->p_functions == NULL ) \
{ \
return( -1 ); \
} \
- STORE_SYMBOLS;
+ STORE_SYMBOLS; \
+ do {
#define MODULE_ACTIVATE_STOP \
+ } while( 0 ); \
return( 0 ); \
}
#define MODULE_DEACTIVATE_START \
int __VLC_SYMBOL( DeactivateModule )( module_t *p_module ) \
{ \
- free( p_module->p_functions );
+ free( p_module->p_functions ); \
+ do {
#define MODULE_DEACTIVATE_STOP \
+ } while( 0 ); \
+ config_UnsetCallbacks( p_module->p_config ); \
return( 0 ); \
}
* configuration.c management of the modules configuration
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: configuration.c,v 1.21 2002/05/01 21:31:53 gbazin Exp $
+ * $Id: configuration.c,v 1.22 2002/05/03 20:49:30 sam Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
vlc_mutex_unlock( p_config->p_lock );
+ if( p_config->p_callback )
+ {
+ ((void(*)(void))p_config->p_callback)();
+ }
}
/*****************************************************************************
}
p_config->i_value = i_value;
+
+ if( p_config->p_callback )
+ {
+ ((void(*)(void))p_config->p_callback)();
+ }
}
/*****************************************************************************
}
p_config->f_value = f_value;
+
+ if( p_config->p_callback )
+ {
+ ((void(*)(void))p_config->p_callback)();
+ }
}
/*****************************************************************************
return p_config;
}
+/*****************************************************************************
+ * config_SetCallbacks: sets callback functions in the duplicate p_config.
+ *****************************************************************************
+ * Unfortunatly we cannot work directly with the module's config data as
+ * this module might be unloaded from memory at any time (remember HideModule).
+ * This is why we need to duplicate callbacks each time we reload the module.
+ *****************************************************************************/
+void config_SetCallbacks( module_config_t *p_new, module_config_t *p_orig )
+{
+ while( p_new->i_type != MODULE_CONFIG_HINT_END )
+ {
+ p_new->p_callback = p_orig->p_callback;
+ p_new++;
+ p_orig++;
+ }
+}
+
+/*****************************************************************************
+ * config_UnsetCallbacks: unsets callback functions in the duplicate p_config.
+ *****************************************************************************
+ * We simply undo what we did in config_SetCallbacks.
+ *****************************************************************************/
+void config_UnsetCallbacks( module_config_t *p_new )
+{
+ while( p_new->i_type != MODULE_CONFIG_HINT_END )
+ {
+ p_new->p_callback = NULL;
+ p_new++;
+ }
+}
+
/*****************************************************************************
* config_LoadConfigFile: loads the configuration file.
*****************************************************************************
* modules_plugin.h : Plugin management functions used by the core application.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: modules_plugin.h,v 1.23 2002/04/30 12:56:11 gbazin Exp $
+ * $Id: modules_plugin.h,v 1.24 2002/05/03 20:49:30 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
(p_symbols)->config_SaveConfigFile = config_SaveConfigFile; \
(p_symbols)->config_Duplicate = config_Duplicate; \
(p_symbols)->config_FindConfig = config_FindConfig; \
+ (p_symbols)->config_SetCallbacks = config_SetCallbacks; \
+ (p_symbols)->config_UnsetCallbacks = config_UnsetCallbacks; \
(p_symbols)->intf_MsgSub = intf_MsgSub; \
(p_symbols)->intf_MsgUnsub = intf_MsgUnsub; \
(p_symbols)->intf_Msg = intf_Msg; \