Commit 959c5560 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use var_AcquireMutex for the "libvlc" lock

parent e4e91829
......@@ -151,7 +151,6 @@ libvlc_int_t * libvlc_InternalCreate( void )
{
int i_ret;
libvlc_int_t * p_libvlc = NULL;
vlc_value_t lockval;
char *psz_env = NULL;
/* vlc_threads_init *must* be the first internal call! No other call is
......@@ -160,10 +159,8 @@ libvlc_int_t * libvlc_InternalCreate( void )
if( i_ret < 0 ) return NULL;
/* Now that the thread system is initialized, we don't have much, but
* at least we have var_Create */
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
* at least we have variables */
vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
i_instances++;
......@@ -176,7 +173,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
p_libvlc_global->b_ready = VLC_TRUE;
}
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
/* Allocate a libvlc instance object */
p_libvlc = vlc_object_create( p_libvlc_global, VLC_OBJECT_LIBVLC );
......@@ -1044,9 +1041,7 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release )
p_libvlc->p_hotkeys );
FREENULL( p_libvlc->p_hotkeys );
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
i_instances--;
if( i_instances == 0 )
......@@ -1054,7 +1049,7 @@ int libvlc_InternalDestroy( libvlc_int_t *p_libvlc, vlc_bool_t b_release )
/* System specific cleaning code */
system_End( p_libvlc );
}
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
msg_Flush( p_libvlc );
msg_Destroy( p_libvlc );
......
......@@ -115,12 +115,9 @@ static void UndupModule ( module_t * );
void __module_InitBank( vlc_object_t *p_this )
{
module_bank_t *p_bank = NULL;
vlc_value_t lockval;
libvlc_global_data_t *p_libvlc_global = vlc_global();
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
if( p_libvlc_global->p_module_bank == NULL )
{
......@@ -146,7 +143,7 @@ void __module_InitBank( vlc_object_t *p_this )
else
p_libvlc_global->p_module_bank->i_usage++;
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
}
......@@ -161,23 +158,20 @@ void __module_InitBank( vlc_object_t *p_this )
void __module_EndBank( vlc_object_t *p_this )
{
module_t * p_next = NULL;
vlc_value_t lockval;
libvlc_global_data_t *p_libvlc_global = vlc_global();
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
if( !p_libvlc_global->p_module_bank )
{
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
return;
}
if( --p_libvlc_global->p_module_bank->i_usage )
{
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
return;
}
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
/* Save the configuration */
config_AutoSaveConfigFile( p_this );
......@@ -247,19 +241,16 @@ void __module_EndBank( vlc_object_t *p_this )
*/
void __module_LoadBuiltins( vlc_object_t * p_this )
{
vlc_value_t lockval;
libvlc_global_data_t *p_libvlc_global = vlc_global();
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
if( p_libvlc_global->p_module_bank->b_builtins )
{
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
return;
}
p_libvlc_global->p_module_bank->b_builtins = VLC_TRUE;
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
msg_Dbg( p_this, "checking builtin modules" );
ALLOCATE_ALL_BUILTINS();
......@@ -276,19 +267,16 @@ void __module_LoadBuiltins( vlc_object_t * p_this )
void __module_LoadPlugins( vlc_object_t * p_this )
{
#ifdef HAVE_DYNAMIC_PLUGINS
vlc_value_t lockval;
libvlc_global_data_t *p_libvlc_global = vlc_global();
var_Create( p_libvlc_global, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc_global, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
vlc_mutex_t *lock = var_AcquireMutex( "libvlc" );
if( p_libvlc_global->p_module_bank->b_plugins )
{
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
return;
}
p_libvlc_global->p_module_bank->b_plugins = VLC_TRUE;
vlc_mutex_unlock( lockval.p_address );
vlc_mutex_unlock( lock );
msg_Dbg( p_this, "checking plugin modules" );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment