]> git.sesse.net Git - vlc/commitdiff
Load plugins and configuration as soon as possible
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 21 Aug 2011 11:13:40 +0000 (14:13 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 21 Aug 2011 11:13:40 +0000 (14:13 +0300)
No need to load the config file twice anymore.

src/libvlc.c
src/modules/bank.c
src/modules/modules.h

index e01452468a22089177a47fe8df12fc16d28d3abb..5fd92cfda712f17a92738f4983792829c647cba1 100644 (file)
@@ -259,18 +259,55 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
      * options) */
     module_InitBank ();
 
+    /* Get command line options that affect module loading. */
     if( config_LoadCmdLine( p_libvlc, i_argc, ppsz_argv, NULL ) )
     {
         module_EndBank (false);
         return VLC_EGENERIC;
     }
-
     priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
-    /* Announce who we are - Do it only for first instance ? */
+
+    /* Announce who we are (TODO: only first instance?) */
     msg_Dbg( p_libvlc, "VLC media player - %s", VERSION_MESSAGE );
     msg_Dbg( p_libvlc, "%s", COPYRIGHT_MESSAGE );
     msg_Dbg( p_libvlc, "revision %s", psz_vlc_changeset );
     msg_Dbg( p_libvlc, "configured with %s", CONFIGURE_LINE );
+
+    /* Load the builtins and plugins into the module_bank.
+     * We have to do it before config_Load*() because this also gets the
+     * list of configuration options exported by each module and loads their
+     * default values. */
+    size_t module_count = module_LoadPlugins (p_libvlc);
+
+    /*
+     * Override default configuration with config file settings
+     */
+    if( !var_InheritBool( p_libvlc, "ignore-config" ) )
+    {
+        if( var_InheritBool( p_libvlc, "reset-config" ) )
+            config_SaveConfigFile( p_libvlc ); /* Save default config */
+        else
+            config_LoadConfigFile( p_libvlc );
+    }
+
+    /*
+     * Override configuration with command line settings
+     */
+    int vlc_optind;
+    if( config_LoadCmdLine( p_libvlc, i_argc, ppsz_argv, &vlc_optind ) )
+    {
+#ifdef WIN32
+        ShowConsole( false );
+        /* Pause the console because it's destroyed when we exit */
+        fprintf( stderr, "The command line options couldn't be loaded, check "
+                 "that they are valid.\n" );
+        PauseConsole();
+#endif
+        module_EndBank (true);
+        return VLC_EGENERIC;
+    }
+    priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
+
     /*xgettext: Translate "C" to the language code: "fr", "en_GB", "nl", "ru"... */
     msg_Dbg( p_libvlc, "translation test: code is \"%s\"", _("C") );
 
@@ -356,7 +393,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 
     if( b_exit )
     {
-        module_EndBank (false);
+        module_EndBank (true);
         return i_ret;
     }
 
@@ -364,10 +401,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 #if defined( ENABLE_NLS ) \
      && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
 # if defined (WIN32) || defined (__APPLE__)
-    if( !var_InheritBool( p_libvlc, "ignore-config" ) )
-        config_LoadConfigFile( p_libvlc );
-    priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
-
     /* Check if the user specified a custom language */
     psz_language = var_CreateGetNonEmptyString( p_libvlc, "language" );
     if( psz_language && strcmp( psz_language, "auto" ) )
@@ -382,19 +415,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 # endif
 #endif
 
-    /*
-     * Load the builtins and plugins into the module_bank.
-     * We have to do it before config_Load*() because this also gets the
-     * list of configuration options exported by each module and loads their
-     * default values.
-     */
-    module_LoadPlugins( p_libvlc );
-
-    size_t module_count;
-    module_t **list = module_list_get( &module_count );
-    module_list_free( list );
-    msg_Dbg( p_libvlc, "module bank initialized (%zu modules)", module_count );
-
     /* Check for help on modules */
     if( (p_tmp = var_InheritString( p_libvlc, "module" )) )
     {
@@ -448,38 +468,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         return i_ret;
     }
 
-    /*
-     * Override default configuration with config file settings
-     */
-    if( !var_InheritBool( p_libvlc, "ignore-config" ) )
-    {
-        if( var_InheritBool( p_libvlc, "reset-config" ) )
-        {
-            config_ResetAll( p_libvlc );
-            config_SaveConfigFile( p_libvlc );
-        }
-        else
-            config_LoadConfigFile( p_libvlc );
-    }
-
-    /*
-     * Override configuration with command line settings
-     */
-    int vlc_optind;
-    if( config_LoadCmdLine( p_libvlc, i_argc, ppsz_argv, &vlc_optind ) )
-    {
-#ifdef WIN32
-        ShowConsole( false );
-        /* Pause the console because it's destroyed when we exit */
-        fprintf( stderr, "The command line options couldn't be loaded, check "
-                 "that they are valid.\n" );
-        PauseConsole();
-#endif
-        module_EndBank (true);
-        return VLC_EGENERIC;
-    }
-    priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
-
 /* FIXME: could be replaced by using Unix sockets */
 #ifdef HAVE_DBUS
     dbus_threads_init_default();
index ece0f8d0d2ac28877b953c523d7868c5d5ca7e16..b001d1bdc947b88742d25f7af4ce6799e0d354f6 100644 (file)
@@ -152,9 +152,9 @@ void module_EndBank (bool b_plugins)
  * Fills the module bank structure with the plugin modules.
  *
  * \param p_this vlc object structure
- * \return nothing
+ * \return total number of modules in bank after loading all plug-ins
  */
-void module_LoadPlugins (vlc_object_t *obj)
+size_t module_LoadPlugins (vlc_object_t *obj)
 {
     /*vlc_assert_locked (&modules.lock); not for static mutexes :( */
 
@@ -168,6 +168,12 @@ void module_LoadPlugins (vlc_object_t *obj)
     }
 #endif
     vlc_mutex_unlock (&modules.lock);
+
+    size_t count;
+    module_t **list = module_list_get (&count);
+    module_list_free (list);
+    msg_Dbg (obj, "plug-ins loaded: %zu modules", count);
+    return count;
 }
 
 /**
index 0356a121b064024adbed1672cd7baf598832ef81..91c29614a25f890f5bb4d7ec6e23d075d6e900e0 100644 (file)
@@ -105,7 +105,7 @@ module_t *vlc_module_create (module_t *);
 void vlc_module_destroy (module_t *);
 
 void module_InitBank (void);
-void module_LoadPlugins( vlc_object_t * );
+size_t module_LoadPlugins( vlc_object_t * );
 #define module_LoadPlugins(a) module_LoadPlugins(VLC_OBJECT(a))
 void module_EndBank (bool);
 int module_Map (vlc_object_t *, module_t *);