- i_ret = VLC_Init( 0, i_argc, ppsz_argv );
- if( i_ret < 0 )
- {
- VLC_Destroy( 0 );
- return i_ret == VLC_EEXITSUCCESS ? 0 : i_ret;
- }
-
- i_ret = VLC_AddIntf( 0, NULL, VLC_TRUE, VLC_TRUE );
-
- /* Finish the threads */
- VLC_CleanUp( 0 );
-
- /* Destroy the libvlc structure */
- VLC_Destroy( 0 );
-
- return i_ret;
-}
-
-#if !defined(WIN32) && !defined(UNDER_CE)
-/*****************************************************************************
- * SigHandler: system signal handler
- *****************************************************************************
- * This function is called when a fatal signal is received by the program.
- * It tries to end the program in a clean way.
- *****************************************************************************/
-static void SigHandler( int i_signal )
-{
- static time_t abort_time = 0;
- static volatile vlc_bool_t b_die = VLC_FALSE;
-
- /* Once a signal has been trapped, the termination sequence will be
- * armed and subsequent signals will be ignored to avoid sending signals
- * to a libvlc structure having been destroyed */
-
- if( !b_die )
- {
- b_die = VLC_TRUE;
- abort_time = time( NULL );
-
- fprintf( stderr, "signal %d received, terminating vlc - do it "
- "again in case it gets stuck\n", i_signal );
+ int i_argc_real = i_argc ? i_argc - 1 : 0;
+ const char **ppsz_argv_real = i_argc ? &ppsz_argv[1] : ppsz_argv;
+ libvlc_instance_t *vlc = libvlc_new (i_argc_real, ppsz_argv_real, &ex);