/*****************************************************************************
* The evil global variable. We handle it with care, don't worry.
*****************************************************************************/
-static libvlc_global_data_t libvlc_global;
-static libvlc_global_data_t *p_libvlc_global = &libvlc_global;
static libvlc_int_t * p_static_vlc = NULL;
static volatile unsigned int i_instances = 0;
static void InitDeviceValues( libvlc_int_t * );
-libvlc_global_data_t *vlc_global( void )
-{
- return p_libvlc_global;
-}
-
/*****************************************************************************
* vlc_current_object: return the current object.
*****************************************************************************
*/
libvlc_int_t * libvlc_InternalCreate( void )
{
- int i_ret;
libvlc_int_t * p_libvlc = NULL;
char *psz_env = NULL;
/* vlc_threads_init *must* be the first internal call! No other call is
* allowed before the thread system has been initialized. */
- i_ret = vlc_threads_init( p_libvlc_global );
- if( i_ret < 0 ) return NULL;
+ if (vlc_threads_init ())
+ return NULL;
+ libvlc_global_data_t *p_libvlc_global = vlc_global();
/* Now that the thread system is initialized, we don't have much, but
* at least we have variables */
vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
p_libvlc->p_playlist = NULL;
p_libvlc->p_interaction = NULL;
p_libvlc->p_vlm = NULL;
- p_libvlc->psz_object_name = "libvlc";
+ p_libvlc->psz_object_name = strdup( "libvlc" );
/* Initialize message queue */
msg_Create( p_libvlc );
vlc_mutex_init( p_libvlc, &p_libvlc->timer_lock );
vlc_mutex_init( p_libvlc, &p_libvlc->config_lock );
#ifdef __APPLE__
- vlc_mutex_init( p_libvlc, &p_libvlc->quicktime_lock );
vlc_thread_set_priority( p_libvlc, VLC_THREAD_PRIORITY_LOW );
#endif
/* Store data for the non-reentrant API */
int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
const char *ppsz_argv[] )
{
+ libvlc_global_data_t *p_libvlc_global = vlc_global();
char p_capabilities[200];
char * p_tmp = NULL;
char * psz_modules = NULL;
/* Get the executable name (similar to the basename command) */
if( i_argc > 0 )
{
- const char *exe = p_libvlc->psz_object_name = ppsz_argv[0];
+ const char *exe = strdup( ppsz_argv[0] );
+ const char *tmp = exe;
while( *exe )
{
if( *exe++ == '/' )
- p_libvlc->psz_object_name = exe;
+ tmp = exe;
}
+ p_libvlc->psz_object_name = strdup( tmp );
}
else
{
- p_libvlc->psz_object_name = "vlc";
+ p_libvlc->psz_object_name = strdup( "vlc" );
}
/*
}
free( psz_modules );
+#ifdef ENABLE_SOUT
/* Initialize VLM if vlm-conf is specified */
psz_parser = config_GetPsz( p_libvlc, "vlm-conf" );
if( psz_parser && *psz_parser )
msg_Err( p_libvlc, "VLM initialization failed" );
}
free( psz_parser );
+#endif
/*
* Load background interfaces
intf_thread_t * p_intf = NULL;
vout_thread_t * p_vout = NULL;
aout_instance_t * p_aout = NULL;
- announce_handler_t * p_announce = NULL;
/* Ask the interfaces to stop and destroy them */
msg_Dbg( p_libvlc, "removing all interfaces" );
aout_Delete( p_aout );
}
+#ifdef ENABLE_SOUT
+ sout_instance_t * p_sout;
+
+ p_sout = vlc_object_find( p_libvlc, VLC_OBJECT_SOUT, FIND_CHILD );
+ if( p_sout )
+ {
+ msg_Dbg( p_sout, "removing kept stream output" );
+ vlc_object_detach( (vlc_object_t*)p_sout );
+ vlc_object_release( (vlc_object_t*)p_sout );
+ sout_DeleteInstance( p_sout );
+ }
+
/* Destroy VLM if created in libvlc_InternalInit */
if( p_libvlc->p_vlm )
{
vlm_Delete( p_libvlc->p_vlm );
}
+#endif
/* Free interaction */
msg_Dbg( p_libvlc, "removing interaction" );
vlc_object_release( p_libvlc->p_interaction );
stats_TimersDumpAll( p_libvlc );
- stats_TimersClean( p_libvlc );
+ stats_TimersCleanAll( p_libvlc );
+
+#ifdef ENABLE_SOUT
+ announce_handler_t * p_announce;
/* Free announce handler(s?) */
while( (p_announce = vlc_object_find( p_libvlc, VLC_OBJECT_ANNOUNCE,
vlc_object_release( p_announce );
announce_HandlerDestroy( p_announce );
}
+#endif
bool b_clean = true;
FOREACH_ARRAY( input_item_t *p_del, p_libvlc->input_items )
/* Stop thread system: last one out please shut the door!
* The number of initializations of the thread system is counted, we
* can call this each time */
- vlc_threads_end( p_libvlc_global );
+ vlc_threads_end ();
return VLC_SUCCESS;
}
}
#ifndef WIN32
- if( p_libvlc_global->b_daemon && b_block && !psz_module )
+ if( vlc_global()->b_daemon && b_block && !psz_module )
{
/* Daemon mode hack.
* We prefer the dummy interface if none is specified. */
#ifdef HAVE_HAL_1
libhal_ctx_shutdown( ctx, NULL );
dbus_connection_unref( p_connection );
+ libhal_ctx_free( ctx );
#else
hal_shutdown( ctx );
#endif