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

vlc_global_mutex: common functions for process-wide mutexes

parent 7c93516a
......@@ -442,4 +442,14 @@ class vlc_mutex_locker
};
#endif
enum {
VLC_AVCODEC_MUTEX = 0,
VLC_GCRYPT_MUTEX,
VLC_MAX_MUTEX
};
VLC_EXPORT( void, vlc_global_mutex, ( unsigned, bool ) );
#define vlc_global_lock( n ) vlc_global_mutex( n, true )
#define vlc_global_unlock( n ) vlc_global_mutex( n, false )
#endif /* !_VLC_THREADS_H */
......@@ -551,6 +551,7 @@ vlc_mutex_init_recursive
vlc_mutex_lock
vlc_mutex_trylock
vlc_mutex_unlock
vlc_global_mutex
vlc_object_attach
vlc_object_create
vlc_object_find
......
......@@ -233,3 +233,24 @@ void vlc_thread_cancel (vlc_object_t *obj)
if (priv->b_thread)
vlc_cancel (priv->thread_id);
}
/*** Global locks ***/
void vlc_global_mutex (unsigned n, bool acquire)
{
static vlc_mutex_t locks[] = {
VLC_STATIC_MUTEX,
VLC_STATIC_MUTEX,
};
assert (n < (sizeof (locks) / sizeof (locks[0])));
vlc_mutex_t *lock = locks + n;
if (acquire)
vlc_mutex_lock (lock);
else
vlc_mutex_unlock (lock);
/* Compile-time assertion ;-) */
char enough_locks[(sizeof (locks) / sizeof (locks[0])) - VLC_MAX_MUTEX];
(void) enough_locks;
}
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