#include <vlc_vlm.h>
/*****************************************************************************
- * The evil global variable. We handle it with care, don't worry.
+ * The evil global variables. We handle them 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 bool b_daemon = false;
+
/*****************************************************************************
* Local prototypes
*****************************************************************************/
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" );
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;
msg_Err( p_libvlc, "Unable to fork vlc to daemon mode" );
b_exit = true;
}
- p_libvlc_global->b_daemon = true;
+ b_daemon = true;
/* lets check if we need to write the pidfile */
psz_pidfile = config_GetPsz( p_libvlc, "pidfile" );
close( STDOUT_FILENO );
close( STDERR_FILENO );
- p_libvlc_global->b_daemon = true;
+ b_daemon = true;
}
#endif
}
/* 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( b_daemon && b_block && !psz_module )
{
/* Daemon mode hack.
* We prefer the dummy interface if none is specified. */