]> git.sesse.net Git - vlc/commitdiff
libvlc: initialize message settings early enough
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 18 Mar 2013 17:09:55 +0000 (19:09 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 18 Mar 2013 17:21:26 +0000 (19:21 +0200)
That is to say, before any message gets logged.

Unfortunately, since the modules bank uses logging, and provides the
configuration, the message settings cannot be stored in the
configuration file. All messages could be removed from the bank but
that would hurt debugging in some cases :-/

src/libvlc-module.c
src/libvlc.c

index 86cee401cb79beea222d0434ac319f8b9d883733..3ed702a48ccc413a54df69d53d1be8bad1fec46e 100644 (file)
@@ -2059,9 +2059,11 @@ vlc_module_begin ()
     add_integer( "verbose", 0, VERBOSE_TEXT, VERBOSE_LONGTEXT,
                  false )
         change_short('v')
+        change_volatile ()
     add_obsolete_string( "verbose-objects" ) /* since 2.1.0 */
     add_bool( "quiet", 0, QUIET_TEXT, QUIET_LONGTEXT, false )
         change_short('q')
+        change_volatile ()
 
 #if !defined(WIN32) && !defined(__OS2__)
     add_bool( "daemon", 0, DAEMON_TEXT, DAEMON_LONGTEXT, true )
@@ -2083,6 +2085,7 @@ vlc_module_begin ()
 #endif
 
     add_bool( "color", true, COLOR_TEXT, COLOR_LONGTEXT, true )
+        change_volatile ()
     add_bool( "advanced", false, ADVANCED_TEXT, ADVANCED_LONGTEXT,
                     false )
     add_bool( "interact", true, INTERACTION_TEXT,
index 16b08655eba438000fb0f8de4df216ae53db9163..ef914913d74ea9b812cf74789702f747b662d124 100644 (file)
@@ -116,12 +116,6 @@ libvlc_int_t * libvlc_InternalCreate( void )
     priv->p_ml = NULL;
     priv->p_dialog_provider = NULL;
     priv->p_vlm = NULL;
-    priv->i_verbose = 3; /* initial value until config is loaded */
-#if defined( HAVE_ISATTY ) && !defined( WIN32 )
-    priv->b_color = isatty( STDERR_FILENO ); /* 2 is for stderr */
-#else
-    priv->b_color = false;
-#endif
 
     /* Initialize mutexes */
     vlc_mutex_init( &priv->ml_lock );
@@ -162,13 +156,27 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         module_EndBank (false);
         return VLC_EGENERIC;
     }
-    priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
 
-    /* Find verbosity from VLC_VERBOSE environment variable */
+    /*
+     * Message queue options (read-only afterwards)
+     */
+#if defined (HAVE_ISATTY) && !defined (WIN32)
+    if (isatty (STDERR_FILENO))
+        priv->b_color = var_InheritBool (p_libvlc, "color");
+    else
+#endif
+        priv->b_color = false;
+
+    priv->i_verbose = var_InheritInteger (p_libvlc, "verbose");
+    psz_val = getenv ("VLC_VERBOSE");
+    if (psz_val != NULL)
+        priv->i_verbose = atoi (psz_val);
+
+    if (var_InheritBool (p_libvlc, "quiet"))
     {
-        char *env = getenv( "VLC_VERBOSE" );
-        if( env != NULL )
-            priv->i_verbose = atoi( env );
+        var_Create (p_libvlc, "verbose", VLC_VAR_INTEGER);
+        var_SetInteger (p_libvlc, "verbose", -1);
+        priv->i_verbose = -1;
     }
 
     /* Announce who we are (TODO: only first instance?) */
@@ -204,7 +212,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         module_EndBank (true);
         return VLC_EGENERIC;
     }
-    priv->i_verbose = var_InheritInteger( p_libvlc, "verbose" );
 
     /*
      * Support for gettext
@@ -381,20 +388,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 dbus_out:
 #endif // HAVE_DBUS
 
-    /*
-     * Message queue options
-     */
-    /* Last chance to set the verbosity. Once we start interfaces and other
-     * threads, verbosity becomes read-only. */
-    var_Create( p_libvlc, "verbose", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-    if( var_InheritBool( p_libvlc, "quiet" ) )
-    {
-        var_SetInteger( p_libvlc, "verbose", -1 );
-        priv->i_verbose = -1;
-    }
-    if( priv->b_color )
-        priv->b_color = var_InheritBool( p_libvlc, "color" );
-
     vlc_CPU_dump( VLC_OBJECT(p_libvlc) );
     vlc_object_set_name( p_libvlc, "main" );