]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
Remove pl_Release, and rename pl_Hold back to pl_Get
[vlc] / src / libvlc.c
index c59c3b43b0edbd4947e6f66d59c959f7cf7b961b..cbc575e498584cd04a0b44cb9c955063d941cc2f 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 );
@@ -810,11 +816,9 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     if( psz_modules )
     {
         char *p = psz_modules, *m;
-        playlist_t *p_playlist = pl_Hold( p_libvlc );
         while( ( m = strsep( &p, " :," ) ) != NULL )
             playlist_ServicesDiscoveryAdd( p_playlist, m );
         free( psz_modules );
-        pl_Release (p_libvlc);
     }
 
 #ifdef ENABLE_VLM
@@ -969,10 +973,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     psz_val = var_InheritString( p_libvlc, "open" );
     if ( psz_val != NULL )
     {
-        playlist_t *p_playlist = pl_Hold( p_libvlc );
         playlist_AddExt( p_playlist, psz_val, NULL, PLAYLIST_INSERT, 0,
                          -1, 0, NULL, 0, true, pl_Unlocked );
-        pl_Release( p_libvlc );
         free( psz_val );
     }
 
@@ -1009,9 +1011,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 +1071,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 );
@@ -1215,11 +1216,9 @@ static int GetFilenames( libvlc_int_t *p_vlc, int i_argc, const char *ppsz_argv[
         if( !mrl )
             continue;
 
-        playlist_t *p_playlist = pl_Hold( p_vlc );
-        playlist_AddExt( p_playlist, mrl, NULL, PLAYLIST_INSERT,
+        playlist_AddExt( pl_Get( p_vlc ), mrl, NULL, PLAYLIST_INSERT,
                 0, -1, i_options, ( i_options ? &ppsz_argv[i_opt + 1] : NULL ),
                 VLC_INPUT_OPTION_TRUSTED, true, pl_Unlocked );
-        pl_Release( p_vlc );
         free( mrl );
     }