[vlc-devel] commit: Don't use a static mutex for libvlc_wait on Win32 (fixes: #3219) ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jan 2 22:16:13 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jan  2 23:14:20 2010 +0200| [36827a8377fd543052f2ccbfab6ba9cac2379889] | committer: Rémi Denis-Courmont 

Don't use a static mutex for libvlc_wait on Win32 (fixes: #3219)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=36827a8377fd543052f2ccbfab6ba9cac2379889
---

 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 da892ac..9469bb2 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 2997f7a..3d7cabd 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 64cdadc..c712ca8 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)
 {




More information about the vlc-devel mailing list