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

core: config_GetPsz -> var_CreateGetNonEmptyString

parent fb1a1c12
...@@ -269,7 +269,10 @@ static inline bool AoutChangeFilterString( vlc_object_t *p_obj, aout_instance_t ...@@ -269,7 +269,10 @@ static inline bool AoutChangeFilterString( vlc_object_t *p_obj, aout_instance_t
if( p_aout ) if( p_aout )
psz_val = var_GetString( p_aout, psz_variable ); psz_val = var_GetString( p_aout, psz_variable );
else else
psz_val = config_GetPsz( p_obj, "audio-filter" ); {
psz_val = var_CreateGetString( p_obj->p_libvlc, "audio-filter" );
var_Destroy( p_obj->p_libvlc, "audio-filter" );
}
if( !psz_val ) if( !psz_val )
psz_val = strdup( "" ); psz_val = strdup( "" );
......
...@@ -54,7 +54,8 @@ static inline char *strdupnull (const char *src) ...@@ -54,7 +54,8 @@ static inline char *strdupnull (const char *src)
*/ */
static char *config_GetConfigFile( vlc_object_t *obj ) static char *config_GetConfigFile( vlc_object_t *obj )
{ {
char *psz_file = config_GetPsz( obj, "config" ); char *psz_file = var_CreateGetNonEmptyString( obj, "config" );
var_Destroy( obj, "config" );
if( psz_file == NULL ) if( psz_file == NULL )
{ {
char *psz_dir = config_GetUserDir( VLC_CONFIG_DIR ); char *psz_dir = config_GetUserDir( VLC_CONFIG_DIR );
......
...@@ -369,7 +369,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -369,7 +369,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
b_daemon = true; b_daemon = true;
/* lets check if we need to write the pidfile */ /* lets check if we need to write the pidfile */
psz_pidfile = config_GetPsz( p_libvlc, "pidfile" ); psz_pidfile = var_CreateGetNonEmptyString( p_libvlc, "pidfile" );
if( psz_pidfile != NULL ) if( psz_pidfile != NULL )
{ {
FILE *pidfile; FILE *pidfile;
...@@ -438,8 +438,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -438,8 +438,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
priv->i_verbose = config_GetInt( p_libvlc, "verbose" ); priv->i_verbose = config_GetInt( p_libvlc, "verbose" );
/* Check if the user specified a custom language */ /* Check if the user specified a custom language */
psz_language = config_GetPsz( p_libvlc, "language" ); psz_language = var_CreateGetNonEmptyString( p_libvlc, "language" );
if( psz_language && *psz_language && strcmp( psz_language, "auto" ) ) if( psz_language && strcmp( psz_language, "auto" ) )
{ {
/* Reset the default domain */ /* Reset the default domain */
SetLanguage( psz_language ); SetLanguage( psz_language );
...@@ -482,7 +482,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -482,7 +482,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
abort(); abort();
} }
/* Check for help on modules */ /* Check for help on modules */
if( (p_tmp = config_GetPsz( p_libvlc, "module" )) ) if( (p_tmp = var_CreateGetNonEmptyString( p_libvlc, "module" )) )
{ {
Help( p_libvlc, p_tmp ); Help( p_libvlc, p_tmp );
free( p_tmp ); free( p_tmp );
...@@ -696,7 +696,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -696,7 +696,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
/* /*
* Message queue options * Message queue options
*/ */
char * psz_verbose_objects = config_GetPsz( p_libvlc, "verbose-objects" ); char * psz_verbose_objects = var_CreateGetNonEmptyString( p_libvlc, "verbose-objects" );
if( psz_verbose_objects ) if( psz_verbose_objects )
{ {
char * psz_object, * iter = psz_verbose_objects; char * psz_object, * iter = psz_verbose_objects;
...@@ -851,8 +851,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -851,8 +851,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
vlc_object_attach( p_playlist, p_libvlc ); vlc_object_attach( p_playlist, p_libvlc );
/* Add service discovery modules */ /* Add service discovery modules */
psz_modules = config_GetPsz( p_playlist, "services-discovery" ); psz_modules = var_CreateGetNonEmptyString( p_playlist, "services-discovery" );
if( psz_modules && *psz_modules ) if( psz_modules )
{ {
char *p = psz_modules, *m; char *p = psz_modules, *m;
while( ( m = strsep( &p, " :," ) ) != NULL ) while( ( m = strsep( &p, " :," ) ) != NULL )
...@@ -862,8 +862,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -862,8 +862,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
#ifdef ENABLE_VLM #ifdef ENABLE_VLM
/* Initialize VLM if vlm-conf is specified */ /* Initialize VLM if vlm-conf is specified */
psz_parser = config_GetPsz( p_libvlc, "vlm-conf" ); psz_parser = var_CreateGetNonEmptyString( p_libvlc, "vlm-conf" );
if( psz_parser && *psz_parser ) if( psz_parser )
{ {
priv->p_vlm = vlm_New( p_libvlc ); priv->p_vlm = vlm_New( p_libvlc );
if( !priv->p_vlm ) if( !priv->p_vlm )
...@@ -879,10 +879,10 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -879,10 +879,10 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
all interfaces as they can use it) */ all interfaces as they can use it) */
var_Create( p_libvlc, "volume-change", VLC_VAR_BOOL ); var_Create( p_libvlc, "volume-change", VLC_VAR_BOOL );
psz_modules = config_GetPsz( p_libvlc, "extraintf" ); psz_modules = var_CreateGetNonEmptyString( p_libvlc, "extraintf" );
psz_control = config_GetPsz( p_libvlc, "control" ); psz_control = var_CreateGetNonEmptyString( p_libvlc, "control" );
if( psz_modules && *psz_modules && psz_control && *psz_control ) if( psz_modules && psz_control )
{ {
char* psz_tmp; char* psz_tmp;
if( asprintf( &psz_tmp, "%s:%s", psz_modules, psz_control ) != -1 ) if( asprintf( &psz_tmp, "%s:%s", psz_modules, psz_control ) != -1 )
...@@ -891,7 +891,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -891,7 +891,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
psz_modules = psz_tmp; psz_modules = psz_tmp;
} }
} }
else if( psz_control && *psz_control ) else if( psz_control )
{ {
free( psz_modules ); free( psz_modules );
psz_modules = strdup( psz_control ); psz_modules = strdup( psz_control );
...@@ -968,19 +968,19 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -968,19 +968,19 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
#ifdef WIN32 #ifdef WIN32
if( config_GetInt( p_libvlc, "prefer-system-codecs") > 0 ) if( config_GetInt( p_libvlc, "prefer-system-codecs") > 0 )
{ {
char *psz_codecs = config_GetPsz( p_playlist, "codec" ); char *psz_codecs = var_CreateGetNonEmptyString( p_playlist, "codec" );
if( psz_codecs ) if( psz_codecs )
{ {
char *psz_morecodecs; char *psz_morecodecs;
if( asprintf(&psz_morecodecs, "%s,dmo,quicktime", psz_codecs) != -1 ) if( asprintf(&psz_morecodecs, "%s,dmo,quicktime", psz_codecs) != -1 )
{ {
config_PutPsz( p_libvlc, "codec", psz_morecodecs); var_SetString( p_libvlc, "codec", psz_morecodecs);
free( psz_morecodecs ); free( psz_morecodecs );
} }
free( psz_codecs );
} }
else else
config_PutPsz( p_libvlc, "codec", "dmo,quicktime"); var_SetString( p_libvlc, "codec", "dmo,quicktime");
free( psz_codecs );
} }
#endif #endif
...@@ -1071,7 +1071,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc ) ...@@ -1071,7 +1071,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
if( b_daemon ) if( b_daemon )
{ {
psz_pidfile = config_GetPsz( p_libvlc, "pidfile" ); psz_pidfile = var_CreateGetNonEmptyString( p_libvlc, "pidfile" );
if( psz_pidfile != NULL ) if( psz_pidfile != NULL )
{ {
msg_Dbg( p_libvlc, "removing pid file %s", psz_pidfile ); msg_Dbg( p_libvlc, "removing pid file %s", psz_pidfile );
...@@ -1146,8 +1146,8 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, char const *psz_module ) ...@@ -1146,8 +1146,8 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, char const *psz_module )
if( !psz_module ) /* requesting the default interface */ if( !psz_module ) /* requesting the default interface */
{ {
char *psz_interface = config_GetPsz( p_libvlc, "intf" ); char *psz_interface = var_CreateGetNonEmptyString( p_libvlc, "intf" );
if( !psz_interface || !*psz_interface ) /* "intf" has not been set */ if( !psz_interface ) /* "intf" has not been set */
{ {
#ifndef WIN32 #ifndef WIN32
if( b_daemon ) if( b_daemon )
...@@ -1164,13 +1164,12 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, char const *psz_module ) ...@@ -1164,13 +1164,12 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, char const *psz_module )
} }
/* Try to create the interface */ /* Try to create the interface */
if( intf_Create( p_libvlc, psz_module ? psz_module : "$intf" ) ) int ret = intf_Create( p_libvlc, psz_module ? psz_module : "$intf" );
{ if( ret )
msg_Err( p_libvlc, "interface \"%s\" initialization failed", msg_Err( p_libvlc, "interface \"%s\" initialization failed",
psz_module ? psz_module : "default" ); psz_module ? psz_module : "default" );
return VLC_EGENERIC; var_Destroy( p_libvlc, "intf" );
} return ret;
return VLC_SUCCESS;
} }
static vlc_mutex_t exit_lock = VLC_STATIC_MUTEX; static vlc_mutex_t exit_lock = VLC_STATIC_MUTEX;
......
...@@ -129,8 +129,8 @@ static const struct ...@@ -129,8 +129,8 @@ static const struct
static void AddCustomRatios( vout_thread_t *p_vout, const char *psz_var, static void AddCustomRatios( vout_thread_t *p_vout, const char *psz_var,
char *psz_list ) char *psz_list )
{ {
if( psz_list && *psz_list ) assert( psz_list );
{
char *psz_cur = psz_list; char *psz_cur = psz_list;
char *psz_next; char *psz_next;
while( psz_cur && *psz_cur ) while( psz_cur && *psz_cur )
...@@ -147,7 +147,6 @@ static void AddCustomRatios( vout_thread_t *p_vout, const char *psz_var, ...@@ -147,7 +147,6 @@ static void AddCustomRatios( vout_thread_t *p_vout, const char *psz_var,
var_Change( p_vout, psz_var, VLC_VAR_ADDCHOICE, &val, &text); var_Change( p_vout, psz_var, VLC_VAR_ADDCHOICE, &val, &text);
psz_cur = psz_next; psz_cur = psz_next;
} }
}
} }
void vout_IntfInit( vout_thread_t *p_vout ) void vout_IntfInit( vout_thread_t *p_vout )
...@@ -244,9 +243,12 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -244,9 +243,12 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_Create( p_vout, "crop-update", VLC_VAR_VOID ); var_Create( p_vout, "crop-update", VLC_VAR_VOID );
/* Add custom crop ratios */ /* Add custom crop ratios */
psz_buf = config_GetPsz( p_vout, "custom-crop-ratios" ); psz_buf = var_CreateGetNonEmptyString( p_vout, "custom-crop-ratios" );
if( psz_buf )
{
AddCustomRatios( p_vout, "crop", psz_buf ); AddCustomRatios( p_vout, "crop", psz_buf );
free( psz_buf ); free( psz_buf );
}
var_AddCallback( p_vout, "crop", CropCallback, NULL ); var_AddCallback( p_vout, "crop", CropCallback, NULL );
var_Get( p_vout, "crop", &old_val ); var_Get( p_vout, "crop", &old_val );
...@@ -305,9 +307,12 @@ void vout_IntfInit( vout_thread_t *p_vout ) ...@@ -305,9 +307,12 @@ void vout_IntfInit( vout_thread_t *p_vout )
} }
/* Add custom aspect ratios */ /* Add custom aspect ratios */
psz_buf = config_GetPsz( p_vout, "custom-aspect-ratios" ); psz_buf = var_CreateGetNonEmptyString( p_vout, "custom-aspect-ratios" );
if( psz_buf )
{
AddCustomRatios( p_vout, "aspect-ratio", psz_buf ); AddCustomRatios( p_vout, "aspect-ratio", psz_buf );
free( psz_buf ); free( psz_buf );
}
var_AddCallback( p_vout, "aspect-ratio", AspectCallback, NULL ); var_AddCallback( p_vout, "aspect-ratio", AspectCallback, NULL );
var_Get( p_vout, "aspect-ratio", &old_val ); var_Get( p_vout, "aspect-ratio", &old_val );
......
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