]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
Remove uninitialized and unsynchronized global stats
[vlc] / src / libvlc.c
index f2974204dd1a2a34beccb179f788d4791c17ff61..1d1d71d7bbcfe1fc3c90e9b8d3bcf933bc08f616 100644 (file)
@@ -222,9 +222,6 @@ static void PauseConsole  ( void );
 #endif
 static int  ConsoleWidth  ( void );
 
-static int  VerboseCallback( vlc_object_t *, char const *,
-                             vlc_value_t, vlc_value_t, void * );
-
 static void InitDeviceValues( libvlc_int_t * );
 
 static vlc_mutex_t global_lock = VLC_STATIC_MUTEX;
@@ -332,7 +329,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
 
     if( config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, true ) )
     {
-        module_EndBank( p_libvlc );
+        module_EndBank( p_libvlc, false );
         return VLC_EGENERIC;
     }
 
@@ -432,7 +429,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     if( b_exit )
     {
         free( priv->psz_configfile );
-        module_EndBank( p_libvlc );
+        module_EndBank( p_libvlc, false );
         return i_ret;
     }
 
@@ -446,6 +443,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     if( !config_GetInt( p_libvlc, "ignore-config" ) )
         config_LoadConfigFile( p_libvlc, "main" );
     config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, true );
+    priv->i_verbose = config_GetInt( p_libvlc, "verbose" );
 
     /* Check if the user specified a custom language */
     psz_language = config_GetPsz( p_libvlc, "language" );
@@ -457,11 +455,12 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         /* Translate "C" to the language code: "fr", "en_GB", "nl", "ru"... */
         msg_Dbg( p_libvlc, "translation test: code is \"%s\"", _("C") );
 
-        module_EndBank( p_libvlc );
+        module_EndBank( p_libvlc, false );
         module_InitBank( p_libvlc );
         if( !config_GetInt( p_libvlc, "ignore-config" ) )
             config_LoadConfigFile( p_libvlc, "main" );
         config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, true );
+        priv->i_verbose = config_GetInt( p_libvlc, "verbose" );
     }
     free( psz_language );
 # endif
@@ -473,7 +472,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
      * list of configuration options exported by each module and loads their
      * default values.
      */
-    module_LoadBuiltins( p_libvlc );
     module_LoadPlugins( p_libvlc, b_cache_delete );
     if( p_libvlc->b_die )
     {
@@ -543,7 +541,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     if( b_exit )
     {
         free( priv->psz_configfile );
-        module_EndBank( p_libvlc );
+        module_EndBank( p_libvlc, true );
         return i_ret;
     }
 
@@ -571,9 +569,10 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         PauseConsole();
 #endif
         free( priv->psz_configfile );
-        module_EndBank( p_libvlc );
+        module_EndBank( p_libvlc, true );
         return VLC_EGENERIC;
     }
+    priv->i_verbose = config_GetInt( p_libvlc, "verbose" );
 
     /*
      * System specific configuration
@@ -721,7 +720,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
                     msg_Err( p_libvlc, "verbose-objects usage: \n"
                             "--verbose-objects=+printthatobject,"
                             "-dontprintthatone\n"
-                            "(keyword 'all' to applies to all objects)\n");
+                            "(keyword 'all' to applies to all objects)");
                     free( psz_verbose_objects );
                     /* FIXME: leaks!!!! */
                     return VLC_EGENERIC;
@@ -730,14 +729,14 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         free( psz_verbose_objects );
     }
 
+    /* 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( config_GetInt( p_libvlc, "quiet" ) > 0 )
     {
-        val.i_int = -1;
-        var_Set( p_libvlc, "verbose", val );
+        var_SetInteger( p_libvlc, "verbose", -1 );
+        priv->i_verbose = -1;
     }
-    var_AddCallback( p_libvlc, "verbose", VerboseCallback, NULL );
-    var_TriggerCallback( p_libvlc, "verbose" );
 
     if( priv->b_color )
         priv->b_color = config_GetInt( p_libvlc, "color" ) > 0;
@@ -792,16 +791,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     priv->i_timers = 0;
     priv->pp_timers = NULL;
 
-    /* Init stats */
-    p_libvlc->p_stats = (global_stats_t *)malloc( sizeof( global_stats_t ) );
-    if( !p_libvlc->p_stats )
-    {
-        vlc_object_release( p_libvlc );
-        return VLC_ENOMEM; /* FIXME: leaks */
-    }
-    vlc_mutex_init( &p_libvlc->p_stats->lock );
-    priv->p_stats_computer = NULL;
-
     priv->i_last_input_id = 0; /* Not very safe, should be removed */
 
     /*
@@ -827,7 +816,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         {
             module_unneed( p_libvlc, priv->p_memcpy_module );
         }
-        module_EndBank( p_libvlc );
+        module_EndBank( p_libvlc, true );
         free( priv->psz_configfile );
         return VLC_EGENERIC;
     }
@@ -983,7 +972,11 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     /*
      * FIXME: kludge to use a p_libvlc-local variable for the Mozilla plugin
      */
+    var_Create( p_libvlc, "drawable-xid", VLC_VAR_INTEGER );
+    var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_ADDRESS );
+#ifdef __APPLE__
     var_Create( p_libvlc, "drawable", VLC_VAR_INTEGER );
+#endif
     var_Create( p_libvlc, "drawable-view-top", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-view-left", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-view-bottom", VLC_VAR_INTEGER );
@@ -1077,8 +1070,6 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     stats_TimersCleanAll( p_libvlc );
 
     msg_Dbg( p_libvlc, "removing stats" );
-    vlc_mutex_destroy( &p_libvlc->p_stats->lock );
-    FREENULL( p_libvlc->p_stats );
 
 #ifndef WIN32
     char* psz_pidfile = NULL;
@@ -1106,7 +1097,7 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     }
 
     /* Free module bank. It is refcounted, so we call this each time  */
-    module_EndBank( p_libvlc );
+    module_EndBank( p_libvlc, true );
 
     FREENULL( priv->psz_configfile );
     var_DelCallback( p_libvlc, "key-pressed", vlc_key_to_action,
@@ -1981,9 +1972,6 @@ static void Version( void )
     utf8_fprintf( stdout, _("Compiled by %s@%s.%s\n"),
              VLC_CompileBy(), VLC_CompileHost(), VLC_CompileDomain() );
     utf8_fprintf( stdout, _("Compiler: %s\n"), VLC_Compiler() );
-    if( strcmp( VLC_Changeset(), "exported" ) )
-        utf8_fprintf( stdout, _("Based upon Git commit [%s]\n"),
-                 VLC_Changeset() );
     utf8_fprintf( stdout, LICENSE_MSG );
 
 #ifdef WIN32        /* Pause the console because it's destroyed when we exit */
@@ -2074,21 +2062,6 @@ static int ConsoleWidth( void )
     return i_width;
 }
 
-static int VerboseCallback( vlc_object_t *p_this, const char *psz_variable,
-                     vlc_value_t old_val, vlc_value_t new_val, void *param)
-{
-    libvlc_int_t *p_libvlc = (libvlc_int_t *)p_this;
-    (void)psz_variable;
-    (void)old_val;
-    (void)param;
-
-    if( new_val.i_int >= -1 )
-    {
-        libvlc_priv (p_libvlc)->i_verbose = __MIN( new_val.i_int, 2 );
-    }
-    return VLC_SUCCESS;
-}
-
 /*****************************************************************************
  * InitDeviceValues: initialize device values
  *****************************************************************************