Commit 3ca1fe82 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use vlc_config_create()

parent 927f27d8
...@@ -211,8 +211,6 @@ VLC_EXPORT( void, __config_ResetAll, ( vlc_object_t * ) ); ...@@ -211,8 +211,6 @@ VLC_EXPORT( void, __config_ResetAll, ( vlc_object_t * ) );
VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) ); VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) );
VLC_EXPORT( int, config_Duplicate,( module_t *, const module_config_t *, size_t ));
VLC_EXPORT(const char *, config_GetDataDir, ( void )); VLC_EXPORT(const char *, config_GetDataDir, ( void ));
VLC_EXPORT( void, __config_AddIntf, ( vlc_object_t *, const char * ) ); VLC_EXPORT( void, __config_AddIntf, ( vlc_object_t *, const char * ) );
...@@ -300,47 +298,39 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) ); ...@@ -300,47 +298,39 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
* allow for a more user friendly interface. * allow for a more user friendly interface.
*****************************************************************************/ *****************************************************************************/
#define add_config_inner( ) \
i_config++; \
if( (i_config % 10) == 0 ) \
p_config = (module_config_t *) \
realloc(p_config, (i_config+11) * sizeof(module_config_t)); \
memset( p_config + i_config, 0, sizeof( *p_config ) )
#define add_type_inner( type ) \ #define add_type_inner( type ) \
add_config_inner( ); \ p_config = vlc_config_create (p_module, type)
p_config[i_config].i_type = type
#define add_typedesc_inner( type, text, longtext ) \ #define add_typedesc_inner( type, text, longtext ) \
add_type_inner( type ); \ add_type_inner( type ); \
vlc_config_set (p_config + i_config, VLC_CONFIG_DESC, \ vlc_config_set (p_config, VLC_CONFIG_DESC, \
(const char *)(text), (const char *)(longtext)) (const char *)(text), (const char *)(longtext))
#define add_typeadv_inner( type, text, longtext, advc ) \ #define add_typeadv_inner( type, text, longtext, advc ) \
add_typedesc_inner( type, text, longtext ); \ add_typedesc_inner( type, text, longtext ); \
if (advc) vlc_config_set (p_config + i_config, VLC_CONFIG_ADVANCED) if (advc) vlc_config_set (p_config, VLC_CONFIG_ADVANCED)
#define add_typename_inner( type, name, text, longtext, advc, cb ) \ #define add_typename_inner( type, name, text, longtext, advc, cb ) \
add_typeadv_inner( type, text, longtext, advc ); \ add_typeadv_inner( type, text, longtext, advc ); \
vlc_config_set (p_config + i_config, VLC_CONFIG_NAME, \ vlc_config_set (p_config, VLC_CONFIG_NAME, \
(const char *)(name), (vlc_callback_t)(cb)) (const char *)(name), (vlc_callback_t)(cb))
#define add_string_inner( type, name, text, longtext, advc, cb, v ) \ #define add_string_inner( type, name, text, longtext, advc, cb, v ) \
add_typename_inner( type, name, text, longtext, advc, cb ); \ add_typename_inner( type, name, text, longtext, advc, cb ); \
vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (const char *)(v)) vlc_config_set (p_config, VLC_CONFIG_VALUE, (const char *)(v))
#define add_int_inner( type, name, text, longtext, advc, cb, v ) \ #define add_int_inner( type, name, text, longtext, advc, cb, v ) \
add_typename_inner( type, name, text, longtext, advc, cb ); \ add_typename_inner( type, name, text, longtext, advc, cb ); \
vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (int)(v)) vlc_config_set (p_config, VLC_CONFIG_VALUE, (int)(v))
#define set_category( i_id ) \ #define set_category( i_id ) \
add_type_inner( CONFIG_CATEGORY ); \ add_type_inner( CONFIG_CATEGORY ); \
p_config[i_config].value.i = i_id p_config->value.i = i_id
#define set_subcategory( i_id ) \ #define set_subcategory( i_id ) \
add_type_inner( CONFIG_SUBCATEGORY ); \ add_type_inner( CONFIG_SUBCATEGORY ); \
p_config[i_config].value.i = i_id p_config->value.i = i_id
#define set_section( text, longtext ) \ #define set_section( text, longtext ) \
add_typedesc_inner( CONFIG_SECTION, text, longtext ) add_typedesc_inner( CONFIG_SECTION, text, longtext )
...@@ -371,22 +361,20 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) ); ...@@ -371,22 +361,20 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
#define add_module( name, psz_caps, value, p_callback, text, longtext, advc ) \ #define add_module( name, psz_caps, value, p_callback, text, longtext, advc ) \
add_string_inner( CONFIG_ITEM_MODULE, name, text, longtext, advc, p_callback, value ); \ add_string_inner( CONFIG_ITEM_MODULE, name, text, longtext, advc, p_callback, value ); \
vlc_config_set (p_config + i_config, VLC_CONFIG_CAPABILITY, \ vlc_config_set (p_config, VLC_CONFIG_CAPABILITY, (const char *)(psz_caps))
(const char *)(psz_caps))
#define add_module_list( name, psz_caps, value, p_callback, text, longtext, advc ) \ #define add_module_list( name, psz_caps, value, p_callback, text, longtext, advc ) \
add_string_inner( CONFIG_ITEM_MODULE_LIST, name, text, longtext, advc, p_callback, value ); \ add_string_inner( CONFIG_ITEM_MODULE_LIST, name, text, longtext, advc, p_callback, value ); \
vlc_config_set (p_config + i_config, VLC_CONFIG_CAPABILITY, \ vlc_config_set (p_config, VLC_CONFIG_CAPABILITY, (const char *)(psz_caps))
(const char *)(psz_caps))
#ifndef __PLUGIN__ #ifndef __PLUGIN__
#define add_module_cat( name, i_subcategory, value, p_callback, text, longtext, advc ) \ #define add_module_cat( name, i_subcategory, value, p_callback, text, longtext, advc ) \
add_string_inner( CONFIG_ITEM_MODULE_CAT, name, text, longtext, advc, p_callback, value ); \ add_string_inner( CONFIG_ITEM_MODULE_CAT, name, text, longtext, advc, p_callback, value ); \
p_config[i_config].min.i = i_subcategory /* gruik */ p_config->min.i = i_subcategory /* gruik */
#define add_module_list_cat( name, i_subcategory, value, p_callback, text, longtext, advc ) \ #define add_module_list_cat( name, i_subcategory, value, p_callback, text, longtext, advc ) \
add_string_inner( CONFIG_ITEM_MODULE_LIST_CAT, name, text, longtext, advc, p_callback, value ); \ add_string_inner( CONFIG_ITEM_MODULE_LIST_CAT, name, text, longtext, advc, p_callback, value ); \
p_config[i_config].min.i = i_subcategory /* gruik */ p_config->min.i = i_subcategory /* gruik */
#endif #endif
#define add_integer( name, value, p_callback, text, longtext, advc ) \ #define add_integer( name, value, p_callback, text, longtext, advc ) \
...@@ -401,7 +389,7 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) ); ...@@ -401,7 +389,7 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
#define add_float( name, v, p_callback, text, longtext, advc ) \ #define add_float( name, v, p_callback, text, longtext, advc ) \
add_typename_inner( CONFIG_ITEM_FLOAT, name, text, longtext, advc, p_callback ); \ add_typename_inner( CONFIG_ITEM_FLOAT, name, text, longtext, advc, p_callback ); \
vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (double)(v)) vlc_config_set (p_config, VLC_CONFIG_VALUE, (double)(v))
#define add_float_with_range( name, value, f_min, f_max, p_callback, text, longtext, advc ) \ #define add_float_with_range( name, value, f_min, f_max, p_callback, text, longtext, advc ) \
add_float( name, value, p_callback, text, longtext, advc ); \ add_float( name, value, p_callback, text, longtext, advc ); \
...@@ -409,14 +397,14 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) ); ...@@ -409,14 +397,14 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
#define add_bool( name, v, p_callback, text, longtext, advc ) \ #define add_bool( name, v, p_callback, text, longtext, advc ) \
add_typename_inner( CONFIG_ITEM_BOOL, name, text, longtext, advc, p_callback ); \ add_typename_inner( CONFIG_ITEM_BOOL, name, text, longtext, advc, p_callback ); \
if (v) vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (int)VLC_TRUE) if (v) vlc_config_set (p_config, VLC_CONFIG_VALUE, (int)VLC_TRUE)
/* For removed option */ /* For removed option */
#define add_obsolete_inner( name, type ) \ #define add_obsolete_inner( name, type ) \
add_type_inner( type ); \ add_type_inner( type ); \
vlc_config_set (p_config + i_config, VLC_CONFIG_NAME, \ vlc_config_set (p_config, VLC_CONFIG_NAME, \
(const char *)(name), (vlc_callback_t)NULL); \ (const char *)(name), (vlc_callback_t)NULL); \
vlc_config_set (p_config + i_config, VLC_CONFIG_REMOVED) vlc_config_set (p_config, VLC_CONFIG_REMOVED)
#define add_obsolete_bool( name ) \ #define add_obsolete_bool( name ) \
add_obsolete_inner( name, CONFIG_ITEM_BOOL ) add_obsolete_inner( name, CONFIG_ITEM_BOOL )
...@@ -433,53 +421,51 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) ); ...@@ -433,53 +421,51 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
/* Modifier macros for the config options (used for fine tuning) */ /* Modifier macros for the config options (used for fine tuning) */
#define add_deprecated_alias( name ) \ #define add_deprecated_alias( name ) \
vlc_config_set (p_config + i_config, VLC_CONFIG_OLDNAME, \ vlc_config_set (p_config, VLC_CONFIG_OLDNAME, (const char *)(name))
(const char *)(name))
#define change_short( ch ) \ #define change_short( ch ) \
vlc_config_set (p_config + i_config, VLC_CONFIG_SHORTCUT, (int)(ch)) vlc_config_set (p_config, VLC_CONFIG_SHORTCUT, (int)(ch))
#define change_string_list( list, list_text, list_update_func ) \ #define change_string_list( list, list_text, list_update_func ) \
vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \ vlc_config_set (p_config, VLC_CONFIG_LIST, \
(size_t)(sizeof (list) / sizeof (char *)), \ (size_t)(sizeof (list) / sizeof (char *)), \
(const char *const *)(list), \ (const char *const *)(list), \
(const char *const *)(list_text)) (const char *const *)(list_text))
#define change_integer_list( list, list_text, list_update_func ) \ #define change_integer_list( list, list_text, list_update_func ) \
vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \ vlc_config_set (p_config, VLC_CONFIG_LIST, \
(size_t)(sizeof (list) / sizeof (int)), \ (size_t)(sizeof (list) / sizeof (int)), \
(const int *)(list), \ (const int *)(list), \
(const char *const *)(list_text)) (const char *const *)(list_text))
#define change_float_list( list, list_text, list_update_func ) \ #define change_float_list( list, list_text, list_update_func ) \
vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \ vlc_config_set (p_config, VLC_CONFIG_LIST, \
(size_t)(sizeof (list) / sizeof (float)), \ (size_t)(sizeof (list) / sizeof (float)), \
(const float *)(list), \ (const float *)(list), \
(const char *const *)(list_text)) (const char *const *)(list_text))
#define change_integer_range( minv, maxv ) \ #define change_integer_range( minv, maxv ) \
vlc_config_set (p_config + i_config, VLC_CONFIG_RANGE, \ vlc_config_set (p_config, VLC_CONFIG_RANGE, (int)(minv), (int)(maxv))
(int)(minv), (int)(maxv))
#define change_float_range( minv, maxv ) \ #define change_float_range( minv, maxv ) \
vlc_config_set (p_config + i_config, VLC_CONFIG_RANGE, \ vlc_config_set (p_config, VLC_CONFIG_RANGE, \
(double)(minv), (double)(maxv)) (double)(minv), (double)(maxv))
#define change_action_add( pf_action, text ) \ #define change_action_add( pf_action, text ) \
vlc_config_set (p_config + i_config, VLC_CONFIG_ADD_ACTION, \ vlc_config_set (p_config, VLC_CONFIG_ADD_ACTION, \
(vlc_callback_t)(pf_action), (const char *)(text)) (vlc_callback_t)(pf_action), (const char *)(text))
#define change_internal() \ #define change_internal() \
vlc_config_set (p_config + i_config, VLC_CONFIG_PRIVATE) vlc_config_set (p_config, VLC_CONFIG_PRIVATE)
#define change_need_restart() \ #define change_need_restart() \
vlc_config_set (p_config + i_config, VLC_CONFIG_RESTART) vlc_config_set (p_config, VLC_CONFIG_RESTART)
#define change_autosave() \ #define change_autosave() \
vlc_config_set (p_config + i_config, VLC_CONFIG_PERSISTENT) vlc_config_set (p_config, VLC_CONFIG_PERSISTENT)
#define change_unsaveable() \ #define change_unsaveable() \
vlc_config_set (p_config + i_config, VLC_CONFIG_VOLATILE) vlc_config_set (p_config, VLC_CONFIG_VOLATILE)
/**************************************************************************** /****************************************************************************
* config_chain_t: * config_chain_t:
......
...@@ -111,7 +111,6 @@ E_(vlc_entry) ( module_t *p_module ); ...@@ -111,7 +111,6 @@ E_(vlc_entry) ( module_t *p_module );
__VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \ __VLC_SYMBOL(vlc_entry) ( module_t *p_module ) \
{ \ { \
int res; \ int res; \
size_t i_config = (size_t)(-1); \
module_config_t *p_config = NULL; \ module_config_t *p_config = NULL; \
if (vlc_module_set (p_module, VLC_MODULE_NAME, \ if (vlc_module_set (p_module, VLC_MODULE_NAME, \
(void *)(MODULE_STRING))) \ (void *)(MODULE_STRING))) \
...@@ -121,10 +120,10 @@ E_(vlc_entry) ( module_t *p_module ); ...@@ -121,10 +120,10 @@ E_(vlc_entry) ( module_t *p_module );
#define vlc_module_end( ) \ #define vlc_module_end( ) \
} \ } \
return config_Duplicate( p_module, p_config, ++i_config ); \ return VLC_SUCCESS; \
\ \
error: \ error: \
/* FIXME: config_Free( p_config ); */ \ /* FIXME: config_Free( p_module ); */ \
/* FIXME: cleanup submodules objects ??? */ \ /* FIXME: cleanup submodules objects ??? */ \
return VLC_EGENERIC; \ return VLC_EGENERIC; \
} \ } \
......
...@@ -34,6 +34,9 @@ extern "C" { ...@@ -34,6 +34,9 @@ extern "C" {
int config_CreateDir( vlc_object_t *, const char * ); int config_CreateDir( vlc_object_t *, const char * );
int config_AutoSaveConfigFile( vlc_object_t * ); int config_AutoSaveConfigFile( vlc_object_t * );
/* TODO: remove this, only used for helper module */
int config_Duplicate( module_t *, module_config_t *, size_t );
void config_Free( module_t * ); void config_Free( module_t * );
void config_SetCallbacks( module_config_t *, module_config_t *, size_t ); void config_SetCallbacks( module_config_t *, module_config_t *, size_t );
......
...@@ -486,7 +486,7 @@ module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name ) ...@@ -486,7 +486,7 @@ module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name )
* this module might be unloaded from memory at any time (remember HideModule). * this module might be unloaded from memory at any time (remember HideModule).
* This is why we need to create an exact copy of the config data. * This is why we need to create an exact copy of the config data.
*****************************************************************************/ *****************************************************************************/
int config_Duplicate( module_t *p_module, const module_config_t *p_orig, int config_Duplicate( module_t *p_module, module_config_t *p_orig,
size_t n ) size_t n )
{ {
const module_config_t *p_item, *p_end = p_orig + n; const module_config_t *p_item, *p_end = p_orig + n;
......
...@@ -46,7 +46,6 @@ block_Realloc ...@@ -46,7 +46,6 @@ block_Realloc
config_ChainCreate config_ChainCreate
config_ChainDestroy config_ChainDestroy
__config_ChainParse __config_ChainParse
config_Duplicate
config_FindConfig config_FindConfig
config_GetDataDir config_GetDataDir
__config_GetFloat __config_GetFloat
......
...@@ -157,7 +157,6 @@ module_config_t *vlc_config_create (module_t *module, int type) ...@@ -157,7 +157,6 @@ module_config_t *vlc_config_create (module_t *module, int type)
module->p_config = tab; module->p_config = tab;
} }
module->confsize++;
memset (tab + confsize, 0, sizeof (tab[confsize])); memset (tab + confsize, 0, sizeof (tab[confsize]));
tab[confsize].i_type = type; tab[confsize].i_type = type;
...@@ -170,6 +169,7 @@ module_config_t *vlc_config_create (module_t *module, int type) ...@@ -170,6 +169,7 @@ module_config_t *vlc_config_create (module_t *module, int type)
module->i_bool_items++; module->i_bool_items++;
} }
module->confsize++;
return tab + confsize; return tab + confsize;
} }
......
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