]> git.sesse.net Git - vlc/blobdiff - lib/core.c
auhal: fixed audio device configuration callback and added an additional callback...
[vlc] / lib / core.c
index b115d37ff72e06a7dfd069251bcfe9ec925810a4..a1a722a2bdb47713ca0de2b56a74bc8630c788c6 100644 (file)
@@ -40,12 +40,12 @@ static const char nomemstr[] = "Insufficient memory";
 
 libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
 {
+    libvlc_threads_init ();
+
     libvlc_instance_t *p_new = malloc (sizeof (*p_new));
     if (unlikely(p_new == NULL))
         return NULL;
 
-    libvlc_init_threads ();
-
     const char *my_argv[argc + 2];
     my_argv[0] = "libvlc"; /* dummy arg0, skipped by getopt() et al */
     for( int i = 0; i < argc; i++ )
@@ -74,8 +74,8 @@ libvlc_instance_t * libvlc_new( int argc, const char *const *argv )
     return p_new;
 
 error:
-    libvlc_deinit_threads ();
     free (p_new);
+    libvlc_threads_deinit ();
     return NULL;
 }
 
@@ -107,7 +107,7 @@ void libvlc_release( libvlc_instance_t *p_instance )
         libvlc_InternalCleanup( p_instance->p_libvlc_int );
         libvlc_InternalDestroy( p_instance->p_libvlc_int );
         free( p_instance );
-        libvlc_deinit_threads ();
+        libvlc_threads_deinit ();
     }
 }
 
@@ -136,10 +136,20 @@ void libvlc_set_exit_handler( libvlc_instance_t *p_i, void (*cb) (void *),
     libvlc_SetExitHandler( p_libvlc, cb, data );
 }
 
+static void libvlc_wait_wakeup( void *data )
+{
+    vlc_sem_post( data );
+}
+
 void libvlc_wait( libvlc_instance_t *p_i )
 {
-    libvlc_int_t *p_libvlc = p_i->p_libvlc_int;
-    libvlc_InternalWait( p_libvlc );
+    vlc_sem_t sem;
+
+    vlc_sem_init( &sem, 0 );
+    libvlc_set_exit_handler( p_i, libvlc_wait_wakeup, &sem );
+    vlc_sem_wait( &sem );
+    libvlc_set_exit_handler( p_i, NULL, NULL );
+    vlc_sem_destroy( &sem );
 }
 
 void libvlc_set_user_agent (libvlc_instance_t *p_i,