[vlc-commits] Load plugins and configuration as soon as possible
Rémi Denis-Courmont
git at videolan.org
Sun Aug 21 13:39:00 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Aug 21 14:13:40 2011 +0300| [b91341a3caf06f2fe6a5e8e5a9570c0003957a63] | committer: Rémi Denis-Courmont
Load plugins and configuration as soon as possible
No need to load the config file twice anymore.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b91341a3caf06f2fe6a5e8e5a9570c0003957a63
---
src/libvlc.c | 92 +++++++++++++++++++++---------------------------
src/modules/bank.c | 10 ++++-
src/modules/modules.h | 2 +-
3 files changed, 49 insertions(+), 55 deletions(-)
diff --git a/src/libvlc.c b/src/libvlc.c
index e014524..5fd92cf 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -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();
diff --git a/src/modules/bank.c b/src/modules/bank.c
index ece0f8d..b001d1b 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -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;
}
/**
diff --git a/src/modules/modules.h b/src/modules/modules.h
index 0356a12..91c2961 100644
--- a/src/modules/modules.h
+++ b/src/modules/modules.h
@@ -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 *);
More information about the vlc-commits
mailing list