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

Load plugins and configuration as soon as possible

No need to load the config file twice anymore.
parent 2ba95974
...@@ -259,18 +259,55 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -259,18 +259,55 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
* options) */ * options) */
module_InitBank (); module_InitBank ();
/* Get command line options that affect module loading. */
if( config_LoadCmdLine( p_libvlc, i_argc, ppsz_argv, NULL ) ) if( config_LoadCmdLine( p_libvlc, i_argc, ppsz_argv, NULL ) )
{ {
module_EndBank (false); module_EndBank (false);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" ); 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, "VLC media player - %s", VERSION_MESSAGE );
msg_Dbg( p_libvlc, "%s", COPYRIGHT_MESSAGE ); msg_Dbg( p_libvlc, "%s", COPYRIGHT_MESSAGE );
msg_Dbg( p_libvlc, "revision %s", psz_vlc_changeset ); msg_Dbg( p_libvlc, "revision %s", psz_vlc_changeset );
msg_Dbg( p_libvlc, "configured with %s", CONFIGURE_LINE ); 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"... */ /*xgettext: Translate "C" to the language code: "fr", "en_GB", "nl", "ru"... */
msg_Dbg( p_libvlc, "translation test: code is \"%s\"", _("C") ); 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, ...@@ -356,7 +393,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if( b_exit ) if( b_exit )
{ {
module_EndBank (false); module_EndBank (true);
return i_ret; return i_ret;
} }
...@@ -364,10 +401,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -364,10 +401,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
#if defined( ENABLE_NLS ) \ #if defined( ENABLE_NLS ) \
&& ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) ) && ( defined( HAVE_GETTEXT ) || defined( HAVE_INCLUDED_GETTEXT ) )
# if defined (WIN32) || defined (__APPLE__) # 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 */ /* Check if the user specified a custom language */
psz_language = var_CreateGetNonEmptyString( p_libvlc, "language" ); psz_language = var_CreateGetNonEmptyString( p_libvlc, "language" );
if( psz_language && strcmp( psz_language, "auto" ) ) if( psz_language && strcmp( psz_language, "auto" ) )
...@@ -382,19 +415,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -382,19 +415,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
# endif # endif
#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 */ /* Check for help on modules */
if( (p_tmp = var_InheritString( p_libvlc, "module" )) ) if( (p_tmp = var_InheritString( p_libvlc, "module" )) )
{ {
...@@ -448,38 +468,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -448,38 +468,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
return i_ret; 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 */ /* FIXME: could be replaced by using Unix sockets */
#ifdef HAVE_DBUS #ifdef HAVE_DBUS
dbus_threads_init_default(); dbus_threads_init_default();
......
...@@ -152,9 +152,9 @@ void module_EndBank (bool b_plugins) ...@@ -152,9 +152,9 @@ void module_EndBank (bool b_plugins)
* Fills the module bank structure with the plugin modules. * Fills the module bank structure with the plugin modules.
* *
* \param p_this vlc object structure * \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 :( */ /*vlc_assert_locked (&modules.lock); not for static mutexes :( */
...@@ -168,6 +168,12 @@ void module_LoadPlugins (vlc_object_t *obj) ...@@ -168,6 +168,12 @@ void module_LoadPlugins (vlc_object_t *obj)
} }
#endif #endif
vlc_mutex_unlock (&modules.lock); 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;
} }
/** /**
......
...@@ -105,7 +105,7 @@ module_t *vlc_module_create (module_t *); ...@@ -105,7 +105,7 @@ module_t *vlc_module_create (module_t *);
void vlc_module_destroy (module_t *); void vlc_module_destroy (module_t *);
void module_InitBank (void); 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)) #define module_LoadPlugins(a) module_LoadPlugins(VLC_OBJECT(a))
void module_EndBank (bool); void module_EndBank (bool);
int module_Map (vlc_object_t *, module_t *); int module_Map (vlc_object_t *, module_t *);
......
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