From 36827a8377fd543052f2ccbfab6ba9cac2379889 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 2 Jan 2010 23:14:20 +0200 Subject: [PATCH] Don't use a static mutex for libvlc_wait on Win32 (fixes: #3219) --- include/vlc_threads.h | 1 + src/libvlc.c | 16 ++++++++++------ src/misc/w32thread.c | 4 ++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/vlc_threads.h b/include/vlc_threads.h index da892ac709..9469bb29b9 100644 --- a/include/vlc_threads.h +++ b/include/vlc_threads.h @@ -106,6 +106,7 @@ typedef pthread_t vlc_thread_t; typedef pthread_mutex_t vlc_mutex_t; #define VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER typedef pthread_cond_t vlc_cond_t; +#define VLC_STATIC_COND PTHREAD_COND_INITIALIZER typedef sem_t vlc_sem_t; typedef pthread_rwlock_t vlc_rwlock_t; typedef pthread_key_t vlc_threadvar_t; diff --git a/src/libvlc.c b/src/libvlc.c index 2997f7af10..3d7cabdb8e 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -1182,7 +1182,15 @@ int libvlc_InternalAddIntf( libvlc_int_t *p_libvlc, char const *psz_module ) return ret; } +#ifndef WIN32 static vlc_mutex_t exit_lock = VLC_STATIC_MUTEX; +static vlc_cond_t exiting = VLC_STATIC_COND; +#else +extern vlc_mutex_t super_mutex; +extern vlc_cond_t super_variable; +# define exit_lock super_mutex +# define exiting super_variable +#endif /** * Waits until the LibVLC instance gets an exit signal. Normally, this happens @@ -1190,11 +1198,9 @@ static vlc_mutex_t exit_lock = VLC_STATIC_MUTEX; */ void libvlc_InternalWait( libvlc_int_t *p_libvlc ) { - libvlc_priv_t *priv = libvlc_priv( p_libvlc ); - vlc_mutex_lock( &exit_lock ); while( vlc_object_alive( p_libvlc ) ) - vlc_cond_wait( &priv->exiting, &exit_lock ); + vlc_cond_wait( &exiting, &exit_lock ); vlc_mutex_unlock( &exit_lock ); } @@ -1204,11 +1210,9 @@ void libvlc_InternalWait( libvlc_int_t *p_libvlc ) */ void libvlc_Quit( libvlc_int_t *p_libvlc ) { - libvlc_priv_t *priv = libvlc_priv( p_libvlc ); - vlc_mutex_lock( &exit_lock ); vlc_object_kill( p_libvlc ); - vlc_cond_broadcast( &priv->exiting ); + vlc_cond_broadcast( &exiting ); vlc_mutex_unlock( &exit_lock ); } diff --git a/src/misc/w32thread.c b/src/misc/w32thread.c index 64cdadc61f..c712ca845b 100644 --- a/src/misc/w32thread.c +++ b/src/misc/w32thread.c @@ -140,8 +140,8 @@ DWORD WaitForMultipleObjectsEx (DWORD nCount, const HANDLE *lpHandles, } #endif -static vlc_mutex_t super_mutex; -static vlc_cond_t super_variable; +vlc_mutex_t super_mutex; +vlc_cond_t super_variable; BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved) { -- 2.39.2