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++ )
return p_new;
error:
- libvlc_deinit_threads ();
free (p_new);
+ libvlc_threads_deinit ();
return NULL;
}
libvlc_InternalCleanup( p_instance->p_libvlc_int );
libvlc_InternalDestroy( p_instance->p_libvlc_int );
free( p_instance );
- libvlc_deinit_threads ();
+ libvlc_threads_deinit ();
}
}
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,