]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
Create preparser and fetcher immediately
[vlc] / src / libvlc.c
index c59c3b43b0edbd4947e6f66d59c959f7cf7b961b..91e16cb65cdb733320e343e9b4dd4914c8d3949d 100644 (file)
@@ -77,6 +77,7 @@
 #include "audio_output/aout_internal.h"
 
 #include <vlc_charset.h>
+#include <vlc_fs.h>
 #include <vlc_cpu.h>
 #include <vlc_url.h>
 
@@ -240,7 +241,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
     }
 
     /* Allocate a libvlc instance object */
-    p_libvlc = __vlc_custom_create( NULL, sizeof (*priv),
+    p_libvlc = vlc_custom_create( (vlc_object_t *)NULL, sizeof (*priv),
                                   VLC_OBJECT_GENERIC, "libvlc" );
     if( p_libvlc != NULL )
         i_instances++;
@@ -255,7 +256,9 @@ libvlc_int_t * libvlc_InternalCreate( void )
     priv->p_vlm = NULL;
 
     /* Initialize message queue */
-    msg_Create( p_libvlc );
+    priv->msg_bank = msg_Create ();
+    if (unlikely(priv->msg_bank == NULL))
+        goto error;
 
     /* Find verbosity from VLC_VERBOSE environment variable */
     psz_env = getenv( "VLC_VERBOSE" );
@@ -273,6 +276,9 @@ libvlc_int_t * libvlc_InternalCreate( void )
     vlc_mutex_init( &priv->timer_lock );
 
     return p_libvlc;
+error:
+    vlc_object_release (p_libvlc);
+    return NULL;
 }
 
 /**
@@ -366,7 +372,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
             pid_t i_pid = getpid ();
             msg_Dbg( p_libvlc, "PID is %d, writing it to %s",
                                i_pid, psz_pidfile );
-            pidfile = utf8_fopen( psz_pidfile,"w" );
+            pidfile = vlc_fopen( psz_pidfile,"w" );
             if( pidfile != NULL )
             {
                 utf8_fprintf( pidfile, "%d", (int)i_pid );
@@ -1009,9 +1015,8 @@ void libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     }
 #endif
 
-    /* Free playlist now */
-    msg_Dbg( p_libvlc, "removing playlist" );
-    vlc_object_release( p_playlist );
+    /* Free playlist now, all threads are gone */
+    playlist_Destroy( p_playlist );
 
     stats_TimersDumpAll( p_libvlc );
     stats_TimersCleanAll( p_libvlc );
@@ -1070,7 +1075,7 @@ void libvlc_InternalDestroy( libvlc_int_t *p_libvlc )
     }
     vlc_mutex_unlock( &global_lock );
 
-    msg_Destroy( p_libvlc );
+    msg_Destroy (priv->msg_bank);
 
     /* Destroy mutexes */
     vlc_mutex_destroy( &priv->timer_lock );