#if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
refs = __sync_add_and_fetch (&p_gc->refs, 1);
-#elif defined (WIN32) && defined (__GNUC__)
- refs = __builtin_choose_expr (sizeof (uintptr_t) == 4,
- InterlockedIncrement (&p_gc->refs),
- InterlockedIncrement64 (&p_gc->refs));
+#elif defined (WIN64)
+ refs = InterlockedIncrement64 (&p_gc->refs);
+#elif defined (WIN32)
+ refs = InterlockedIncrement (&p_gc->refs);
#elif defined(__APPLE__)
refs = OSAtomicIncrement32Barrier((int*)&p_gc->refs);
#else
#if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
refs = __sync_sub_and_fetch (&p_gc->refs, 1);
-#elif defined (WIN32) && defined (__GNUC__)
- refs = __builtin_choose_expr (sizeof (uintptr_t) == 4,
- InterlockedDecrement (&p_gc->refs),
- InterlockedDecrement64 (&p_gc->refs));
+#elif defined (WIN64)
+ refs = InterlockedDecrement64 (&p_gc->refs);
+#elif defined (WIN32)
+ refs = InterlockedDecrement (&p_gc->refs);
#elif defined(__APPLE__)
refs = OSAtomicDecrement32Barrier((int*)&p_gc->refs);
#else
static void InitDeviceValues( libvlc_int_t * );
+static vlc_mutex_t global_lock = VLC_STATIC_MUTEX;
+
/**
* Allocate a libvlc instance, initialize global data if needed
* It also initializes the threading system
/* 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" );
+ vlc_mutex_lock( &global_lock );
if( i_instances == 0 )
{
/* Guess what CPU we have */
cpu_flags = CPUCapabilities();
/* The module bank will be initialized later */
- p_module_bank = NULL;
}
/* Allocate a libvlc instance object */
VLC_OBJECT_GENERIC, "libvlc" );
if( p_libvlc != NULL )
i_instances++;
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
if( p_libvlc == NULL )
return NULL;
priv->psz_configfile = config_GetCustomConfigFile( p_libvlc );
/* Check for plugins cache options */
- if( config_GetInt( p_libvlc, "reset-plugins-cache" ) > 0 )
- {
- p_module_bank->b_cache_delete = true;
- }
+ bool b_cache_delete = config_GetInt( p_libvlc, "reset-plugins-cache" ) > 0;
/* Will be re-done properly later on */
priv->i_verbose = config_GetInt( p_libvlc, "verbose" );
psz_language = config_GetPsz( p_libvlc, "language" );
if( psz_language && *psz_language && strcmp( psz_language, "auto" ) )
{
- bool b_cache_delete = p_module_bank->b_cache_delete;
-
/* Reset the default domain */
SetLanguage( psz_language );
if( !config_GetInt( p_libvlc, "ignore-config" ) )
config_LoadConfigFile( p_libvlc, "main" );
config_LoadCmdLine( p_libvlc, &i_argc, ppsz_argv, true );
- p_module_bank->b_cache_delete = b_cache_delete;
}
free( psz_language );
# endif
* default values.
*/
module_LoadBuiltins( p_libvlc );
- module_LoadPlugins( p_libvlc );
+ module_LoadPlugins( p_libvlc, b_cache_delete );
if( p_libvlc->b_die )
{
b_exit = true;
size_t module_count;
module_t **list = module_list_get( &module_count );
module_list_free( list );
- msg_Dbg( p_libvlc, "module bank initialized (%u modules)", module_count );
+ msg_Dbg( p_libvlc, "module bank initialized (%zu modules)", module_count );
/* Check for help on modules */
if( (p_tmp = config_GetPsz( p_libvlc, "module" )) )
if( priv->b_color )
priv->b_color = config_GetInt( p_libvlc, "color" ) > 0;
- /*
- * Output messages that may still be in the queue
- */
- msg_Flush( p_libvlc );
-
if( !config_GetInt( p_libvlc, "fpu" ) )
cpu_flags &= ~CPU_CAPABILITY_FPU;
/*
* Choose the best memcpy module
*/
- priv->p_memcpy_module = module_need( p_libvlc, "memcpy", "$memcpy", 0 );
+ priv->p_memcpy_module = module_need( p_libvlc, "memcpy", "$memcpy", false );
priv->b_stats = config_GetInt( p_libvlc, "stats" ) > 0;
priv->i_timers = 0;
*psz_parser = '\0';
psz_parser++;
}
- psz_temp = (char *)malloc( strlen(psz_module) + sizeof(",none") );
- if( psz_temp )
+ if( asprintf( &psz_temp, "%s,none", psz_module ) != -1)
{
- sprintf( psz_temp, "%s,none", psz_module );
libvlc_InternalAddIntf( p_libvlc, psz_temp );
free( psz_temp );
}
}
#endif
- if( config_GetInt( p_libvlc, "file-logging" ) > 0 )
+ if( (config_GetInt( p_libvlc, "file-logging" ) > 0) &&
+ !config_GetInt( p_libvlc, "syslog" ) )
{
libvlc_InternalAddIntf( p_libvlc, "logger,none" );
}
p_libvlc->p_hotkeys );
FREENULL( p_libvlc->p_hotkeys );
- vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
+ vlc_mutex_lock( &global_lock );
i_instances--;
if( i_instances == 0 )
/* System specific cleaning code */
system_End( p_libvlc );
}
- vlc_mutex_unlock( lock );
+ vlc_mutex_unlock( &global_lock );
- msg_Flush( p_libvlc );
msg_Destroy( p_libvlc );
/* Destroy mutexes */