[vlc-commits] win32: use the new mutex checks
Rémi Denis-Courmont
git at videolan.org
Sun Oct 21 13:01:28 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 20 22:36:49 2018 +0300| [0597f77d4857f9a27a956adf0e0f26cc9b18dde9] | committer: Rémi Denis-Courmont
win32: use the new mutex checks
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0597f77d4857f9a27a956adf0e0f26cc9b18dde9
---
src/libvlc.h | 2 +-
src/win32/thread.c | 24 ++++++++++++++++--------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/src/libvlc.h b/src/libvlc.h
index e36c135304..f6598bb159 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -83,7 +83,7 @@ bool vlc_mutex_marked(const vlc_mutex_t *);
*/
#define vlc_mutex_assert(m) assert(vlc_mutex_marked(m))
-#if !(defined (_WIN32) || defined (__OS2__))
+#if !defined (__OS2__)
#define vlc_assert_locked(m) vlc_mutex_assert(m)
#else
# define vlc_assert_locked( m ) (void)m
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 930b8a8f81..5438e82562 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -104,29 +104,36 @@ void vlc_mutex_lock (vlc_mutex_t *p_mutex)
}
p_mutex->locked = true;
LeaveCriticalSection(&super_mutex);
- return;
}
+ else
+ EnterCriticalSection (&p_mutex->mutex);
- EnterCriticalSection (&p_mutex->mutex);
+ vlc_mutex_mark(p_mutex);
}
int vlc_mutex_trylock (vlc_mutex_t *p_mutex)
{
+ int ret;
+
if (!p_mutex->dynamic)
{ /* static mutexes */
- int ret = EBUSY;
-
EnterCriticalSection(&super_mutex);
if (!p_mutex->locked)
{
p_mutex->locked = true;
ret = 0;
}
+ else
+ ret = EBUSY;
LeaveCriticalSection(&super_mutex);
- return ret;
}
+ else
+ ret = TryEnterCriticalSection (&p_mutex->mutex) ? 0 : EBUSY;
+
+ if (ret == 0)
+ vlc_mutex_mark(p_mutex);
- return TryEnterCriticalSection (&p_mutex->mutex) ? 0 : EBUSY;
+ return ret;
}
void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
@@ -139,10 +146,11 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
if (p_mutex->contention)
WakeAllConditionVariable(&super_variable);
LeaveCriticalSection(&super_mutex);
- return;
}
+ else
+ LeaveCriticalSection (&p_mutex->mutex);
- LeaveCriticalSection (&p_mutex->mutex);
+ vlc_mutex_unmark(p_mutex);
}
/*** Semaphore ***/
More information about the vlc-commits
mailing list