[vlc-commits] libvlc: initialize message settings early enough

Rémi Denis-Courmont git at videolan.org
Mon Mar 18 18:21:30 CET 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar 18 19:09:55 2013 +0200| [4151f94e2f1db403b96fed5f23ccec4104759070] | committer: Rémi Denis-Courmont

libvlc: initialize message settings early enough

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 :-/

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4151f94e2f1db403b96fed5f23ccec4104759070
---

 src/libvlc-module.c |    3 +++
 src/libvlc.c        |   45 +++++++++++++++++++--------------------------
 2 files changed, 22 insertions(+), 26 deletions(-)

diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 86cee40..3ed702a 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -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,
diff --git a/src/libvlc.c b/src/libvlc.c
index 16b0865..ef91491 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -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" );
 



More information about the vlc-commits mailing list