X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Flibvlc.c;h=91e16cb65cdb733320e343e9b4dd4914c8d3949d;hb=14ee5f1254c0aa7cb2e4c01a99fd4d61b009f7e9;hp=c59c3b43b0edbd4947e6f66d59c959f7cf7b961b;hpb=023c65cf894071643b6975161c1c6c837f8b20d3;p=vlc diff --git a/src/libvlc.c b/src/libvlc.c index c59c3b43b0..91e16cb65c 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -77,6 +77,7 @@ #include "audio_output/aout_internal.h" #include +#include #include #include @@ -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 );