]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
decoder: fix data race in sout
[vlc] / src / libvlc.c
index 21f9d4a1614cb576fb1ecc58bbb5ea53055ac79e..cff3784c1660d59886f8ce6e58967df8811a4fbc 100644 (file)
 static void GetFilenames  ( libvlc_int_t *, unsigned, const char *const [] );
 
 /**
- * Allocate a libvlc instance, initialize global data if needed
- * It also initializes the threading system
+ * Allocate a blank libvlc instance, also setting the exit handler.
+ * Vlc's threading system must have been initialized first
  */
 libvlc_int_t * libvlc_InternalCreate( void )
 {
     libvlc_int_t *p_libvlc;
     libvlc_priv_t *priv;
 
-    /* Now that the thread system is initialized, we don't have much, but
-     * at least we have variables */
     /* Allocate a libvlc instance object */
     p_libvlc = vlc_custom_create( (vlc_object_t *)NULL, sizeof (*priv),
                                   "libvlc" );
@@ -130,6 +128,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     /* System specific initialization code */
     system_Init();
 
+    vlc_LogPreinit(p_libvlc);
+
     /* Initialize the module bank and load the configuration of the
      * core module. We need to do this at this stage to be able to display
      * a short help if required by the user. (short help == core module
@@ -143,7 +143,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         return VLC_EGENERIC;
     }
 
-    vlc_LogInit (p_libvlc);
     vlc_threads_setup (p_libvlc);
 
     /* Load the builtins and plugins into the module_bank.
@@ -169,11 +168,13 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     int vlc_optind;
     if( config_LoadCmdLine( p_libvlc, i_argc, ppsz_argv, &vlc_optind ) )
     {
-        module_EndBank (true);
         vlc_LogDeinit (p_libvlc);
+        module_EndBank (true);
         return VLC_EGENERIC;
     }
 
+    vlc_LogInit(p_libvlc);
+
     /*
      * Support for gettext
      */
@@ -193,8 +194,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     if( module_count <= 1 )
     {
         msg_Err( p_libvlc, "No plugins found! Check your VLC installation.");
-        module_EndBank (true);
         vlc_LogDeinit (p_libvlc);
+        module_EndBank (true);
         return VLC_ENOMOD;
     }
 
@@ -205,8 +206,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         if( daemon( 1, 0) != 0 )
         {
             msg_Err( p_libvlc, "Unable to fork vlc to daemon mode" );
-            module_EndBank (true);
             vlc_LogDeinit (p_libvlc);
+            module_EndBank (true);
             return VLC_ENOMEM;
         }
 
@@ -454,25 +455,6 @@ dbus_out:
     free( psz_modules );
     free( psz_control );
 
-#ifdef HAVE_SYSLOG_H
-    if( var_InheritBool( p_libvlc, "syslog" ) )
-    {
-        char *logmode = var_CreateGetNonEmptyString( p_libvlc, "logmode" );
-        var_SetString( p_libvlc, "logmode", "syslog" );
-        libvlc_InternalAddIntf( p_libvlc, "logger,none" );
-
-        if( logmode )
-        {
-            var_SetString( p_libvlc, "logmode", logmode );
-            free( logmode );
-        }
-        var_Destroy( p_libvlc, "logmode" );
-    }
-    else
-#endif
-    if( var_InheritBool( p_libvlc, "file-logging" ) )
-        libvlc_InternalAddIntf( p_libvlc, "logger,none" );
-
     if( var_InheritBool( p_libvlc, "network-synchronisation") )
         libvlc_InternalAddIntf( p_libvlc, "netsync,none" );
 
@@ -487,9 +469,6 @@ dbus_out:
     var_Create( p_libvlc, "drawable-clip-right", VLC_VAR_INTEGER );
     var_Create( p_libvlc, "drawable-nsobject", VLC_VAR_ADDRESS );
 #endif
-#if defined (_WIN32) || defined (__OS2__)
-    var_Create( p_libvlc, "drawable-hwnd", VLC_VAR_INTEGER );
-#endif
 
     /*
      * Get input filenames given as commandline arguments.
@@ -554,8 +533,8 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
         config_AutoSaveConfigFile( VLC_OBJECT(p_libvlc) );
 
     /* Free module bank. It is refcounted, so we call this each time  */
-    module_EndBank (true);
     vlc_LogDeinit (p_libvlc);
+    module_EndBank (true);
 #if defined(_WIN32) || defined(__OS2__)
     system_End( );
 #endif
@@ -621,14 +600,15 @@ static void GetFilenames( libvlc_int_t *p_vlc, unsigned n,
  * Requests extraction of the meta data for an input item (a.k.a. preparsing).
  * The actual extraction is asynchronous.
  */
-int libvlc_MetaRequest(libvlc_int_t *libvlc, input_item_t *item)
+int libvlc_MetaRequest(libvlc_int_t *libvlc, input_item_t *item,
+                       input_item_meta_request_option_t i_options)
 {
     libvlc_priv_t *priv = libvlc_priv(libvlc);
 
     if (unlikely(priv->parser == NULL))
         return VLC_ENOMEM;
 
-    playlist_preparser_Push(priv->parser, item);
+    playlist_preparser_Push(priv->parser, item, i_options);
     return VLC_SUCCESS;
 }
 
@@ -636,13 +616,14 @@ int libvlc_MetaRequest(libvlc_int_t *libvlc, input_item_t *item)
  * Requests retrieving/downloading art for an input item.
  * The retrieval is performed asynchronously.
  */
-int libvlc_ArtRequest(libvlc_int_t *libvlc, input_item_t *item)
+int libvlc_ArtRequest(libvlc_int_t *libvlc, input_item_t *item,
+                      input_item_meta_request_option_t i_options)
 {
     libvlc_priv_t *priv = libvlc_priv(libvlc);
 
     if (unlikely(priv->parser == NULL))
         return VLC_ENOMEM;
 
-    playlist_preparser_fetcher_Push(priv->parser, item);
+    playlist_preparser_fetcher_Push(priv->parser, item, i_options);
     return VLC_SUCCESS;
 }