]> git.sesse.net Git - vlc/commitdiff
libvlc: look the value of intf up only once when used
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 1 Jan 2014 16:52:01 +0000 (18:52 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 1 Jan 2014 16:52:43 +0000 (18:52 +0200)
src/interface/interface.c
src/libvlc.c

index 52b13445fd7e1c8a0ae0a37c614d00b55f93265f..a51cbe3fcc7ac2244c979290888a2f037a682cc5 100644 (file)
@@ -102,15 +102,10 @@ int intf_Create( vlc_object_t *p_this, const char *chain )
     var_AddCallback( p_intf, "intf-add", AddIntfCallback, NULL );
 
     /* Choose the best module */
-    p_intf->p_cfg = NULL;
-    char *psz_parser = *chain == '$'
-                     ? var_CreateGetString(p_intf, chain+1)
-                     : strdup( chain );
     char *module;
-    char *psz_tmp = config_ChainCreate( &module, &p_intf->p_cfg,
-                                        psz_parser );
-    free( psz_tmp );
-    free( psz_parser );
+
+    p_intf->p_cfg = NULL;
+    free( config_ChainCreate( &module, &p_intf->p_cfg, chain ) );
     p_intf->p_module = module_need( p_intf, "interface", module, true );
     free(module);
     if( p_intf->p_module == NULL )
index f79563e9ac98faae967856a65c15b6408ad646e2..933941e25dec0e181eaca23a6e137be153d6a075 100644 (file)
@@ -594,17 +594,19 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
 /**
  * Add an interface plugin and run it
  */
-int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, char const *psz_module )
+int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, const char *name )
 {
+    int ret;
+
     if( !p_libvlc )
         return VLC_EGENERIC;
 
-    if( psz_module == NULL ) /* requesting the default interface */
-    {
+    if( name != NULL )
+        ret = intf_Create( p_libvlc, name );
+    else
+    {   /* Default interface */
         char *intf = var_InheritString( p_libvlc, "intf" );
-        if( intf != NULL ) /* "intf" has not been set */
-            free( intf );
-        else
+        if( intf == NULL ) /* "intf" has not been set */
         {
             char *pidfile = var_InheritString( p_libvlc, "pidfile" );
             if( pidfile != NULL )
@@ -614,13 +616,11 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, char const *psz_module )
                           _("Running vlc with the default interface. "
                             "Use 'cvlc' to use vlc without interface.") );
         }
+        ret = intf_Create( p_libvlc, intf );
+        name = "default";
     }
-
-    /* Try to create the interface */
-    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" );
+        msg_Err( p_libvlc, "interface \"%s\" initialization failed", name );
     return ret;
 }