]> git.sesse.net Git - vlc/commitdiff
core: config_GetPsz -> var_CreateGetNonEmptyString
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 10 Dec 2009 16:44:20 +0000 (18:44 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 10 Dec 2009 16:44:20 +0000 (18:44 +0200)
src/audio_output/aout_internal.h
src/config/file.c
src/libvlc.c
src/video_output/vout_intf.c

index 6ef8da46cd339d4ee01e0469165abbd0bdaacca1..976b730c8f553170e1b006eb7ff11e948151ed24 100644 (file)
@@ -269,7 +269,10 @@ static inline bool AoutChangeFilterString( vlc_object_t *p_obj, aout_instance_t
     if( p_aout )
         psz_val = var_GetString( p_aout, psz_variable );
     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 )
         psz_val = strdup( "" );
index 097a699e157b5a41382c54757a2d7524eb230057..60c2cf05a880adee008b6dc92f0f0e36896d2bdd 100644 (file)
@@ -54,7 +54,8 @@ static inline char *strdupnull (const char *src)
  */
 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 )
     {
         char *psz_dir = config_GetUserDir( VLC_CONFIG_DIR );
index 558595e8f006456cad273dcbad96559f4110abc8..fbe9ccf0f6ae30c6b9c1a8e3154ef8d86783f839 100644 (file)
@@ -369,7 +369,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         b_daemon = true;
 
         /* 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 )
         {
             FILE *pidfile;
@@ -438,8 +438,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     priv->i_verbose = config_GetInt( p_libvlc, "verbose" );
 
     /* Check if the user specified a custom language */
-    psz_language = config_GetPsz( p_libvlc, "language" );
-    if( psz_language && *psz_language && strcmp( psz_language, "auto" ) )
+    psz_language = var_CreateGetNonEmptyString( p_libvlc, "language" );
+    if( psz_language && strcmp( psz_language, "auto" ) )
     {
         /* Reset the default domain */
         SetLanguage( psz_language );
@@ -482,7 +482,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         abort();
     }
     /* 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 );
         free( p_tmp );
@@ -696,7 +696,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     /*
      * 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 )
     {
         char * psz_object, * iter = psz_verbose_objects;
@@ -851,8 +851,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     vlc_object_attach( p_playlist, p_libvlc );
 
     /* Add service discovery modules */
-    psz_modules = config_GetPsz( p_playlist, "services-discovery" );
-    if( psz_modules && *psz_modules )
+    psz_modules = var_CreateGetNonEmptyString( p_playlist, "services-discovery" );
+    if( psz_modules )
     {
         char *p = psz_modules, *m;
         while( ( m = strsep( &p, " :," ) ) != NULL )
@@ -862,8 +862,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 
 #ifdef ENABLE_VLM
     /* Initialize VLM if vlm-conf is specified */
-    psz_parser = config_GetPsz( p_libvlc, "vlm-conf" );
-    if( psz_parser && *psz_parser )
+    psz_parser = var_CreateGetNonEmptyString( p_libvlc, "vlm-conf" );
+    if( psz_parser )
     {
         priv->p_vlm = vlm_New( p_libvlc );
         if( !priv->p_vlm )
@@ -879,10 +879,10 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
        all interfaces as they can use it) */
     var_Create( p_libvlc, "volume-change", VLC_VAR_BOOL );
 
-    psz_modules = config_GetPsz( p_libvlc, "extraintf" );
-    psz_control = config_GetPsz( p_libvlc, "control" );
+    psz_modules = var_CreateGetNonEmptyString( p_libvlc, "extraintf" );
+    psz_control = var_CreateGetNonEmptyString( p_libvlc, "control" );
 
-    if( psz_modules && *psz_modules && psz_control && *psz_control )
+    if( psz_modules && psz_control )
     {
         char* psz_tmp;
         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,
             psz_modules = psz_tmp;
         }
     }
-    else if( psz_control && *psz_control )
+    else if( psz_control )
     {
         free( psz_modules );
         psz_modules = strdup( psz_control );
@@ -968,19 +968,19 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 #ifdef WIN32
     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 )
         {
             char *psz_morecodecs;
             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_codecs );
         }
         else
-            config_PutPsz( p_libvlc, "codec", "dmo,quicktime");
-        free( psz_codecs );
+            var_SetString( p_libvlc, "codec", "dmo,quicktime");
     }
 #endif
 
@@ -1071,7 +1071,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
 
     if( b_daemon )
     {
-        psz_pidfile = config_GetPsz( p_libvlc, "pidfile" );
+        psz_pidfile = var_CreateGetNonEmptyString( p_libvlc, "pidfile" );
         if( psz_pidfile != NULL )
         {
             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 )
 
     if( !psz_module ) /* requesting the default interface */
     {
-        char *psz_interface = config_GetPsz( p_libvlc, "intf" );
-        if( !psz_interface || !*psz_interface ) /* "intf" has not been set */
+        char *psz_interface = var_CreateGetNonEmptyString( p_libvlc, "intf" );
+        if( !psz_interface ) /* "intf" has not been set */
         {
 #ifndef WIN32
             if( b_daemon )
@@ -1164,13 +1164,12 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, char const *psz_module )
     }
 
     /* 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",
                  psz_module ? psz_module : "default" );
-        return VLC_EGENERIC;
-    }
-    return VLC_SUCCESS;
+    var_Destroy( p_libvlc, "intf" );
+    return ret;
 }
 
 static vlc_mutex_t exit_lock = VLC_STATIC_MUTEX;
index f05ad3c2774956f0b7f0be51d1aa99666725ee6c..969597f246d0e2f705c63348eb9c45cecf9d9f13 100644 (file)
@@ -129,24 +129,23 @@ static const struct
 static void AddCustomRatios( vout_thread_t *p_vout, const char *psz_var,
                              char *psz_list )
 {
-    if( psz_list && *psz_list )
+    assert( psz_list );
+
+    char *psz_cur = psz_list;
+    char *psz_next;
+    while( psz_cur && *psz_cur )
     {
-        char *psz_cur = psz_list;
-        char *psz_next;
-        while( psz_cur && *psz_cur )
+        vlc_value_t val, text;
+        psz_next = strchr( psz_cur, ',' );
+        if( psz_next )
         {
-            vlc_value_t val, text;
-            psz_next = strchr( psz_cur, ',' );
-            if( psz_next )
-            {
-                *psz_next = '\0';
-                psz_next++;
-            }
-            val.psz_string = psz_cur;
-            text.psz_string = psz_cur;
-            var_Change( p_vout, psz_var, VLC_VAR_ADDCHOICE, &val, &text);
-            psz_cur = psz_next;
+            *psz_next = '\0';
+            psz_next++;
         }
+        val.psz_string = psz_cur;
+        text.psz_string = psz_cur;
+        var_Change( p_vout, psz_var, VLC_VAR_ADDCHOICE, &val, &text);
+        psz_cur = psz_next;
     }
 }
 
@@ -244,9 +243,12 @@ void vout_IntfInit( vout_thread_t *p_vout )
     var_Create( p_vout, "crop-update", VLC_VAR_VOID );
 
     /* Add custom crop ratios */
-    psz_buf = config_GetPsz( p_vout, "custom-crop-ratios" );
-    AddCustomRatios( p_vout, "crop", psz_buf );
-    free( psz_buf );
+    psz_buf = var_CreateGetNonEmptyString( p_vout, "custom-crop-ratios" );
+    if( psz_buf )
+    {
+        AddCustomRatios( p_vout, "crop", psz_buf );
+        free( psz_buf );
+    }
 
     var_AddCallback( p_vout, "crop", CropCallback, NULL );
     var_Get( p_vout, "crop", &old_val );
@@ -305,9 +307,12 @@ void vout_IntfInit( vout_thread_t *p_vout )
     }
 
     /* Add custom aspect ratios */
-    psz_buf = config_GetPsz( p_vout, "custom-aspect-ratios" );
-    AddCustomRatios( p_vout, "aspect-ratio", psz_buf );
-    free( psz_buf );
+    psz_buf = var_CreateGetNonEmptyString( p_vout, "custom-aspect-ratios" );
+    if( psz_buf )
+    {
+        AddCustomRatios( p_vout, "aspect-ratio", psz_buf );
+        free( psz_buf );
+    }
 
     var_AddCallback( p_vout, "aspect-ratio", AspectCallback, NULL );
     var_Get( p_vout, "aspect-ratio", &old_val );