[vlc-commits] os2: use the new mutex checks
Rémi Denis-Courmont
git at videolan.org
Sun Oct 21 13:01:29 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct 20 22:36:49 2018 +0300| [517a8d4a189e80df44afa9c74b90a052f6b54e74] | committer: Rémi Denis-Courmont
os2: use the new mutex checks
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=517a8d4a189e80df44afa9c74b90a052f6b54e74
---
src/libvlc.h | 4 ----
src/os2/thread.c | 24 ++++++++++++++++--------
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/libvlc.h b/src/libvlc.h
index f6598bb159..6e7ab1727b 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -83,11 +83,7 @@ bool vlc_mutex_marked(const vlc_mutex_t *);
*/
#define vlc_mutex_assert(m) assert(vlc_mutex_marked(m))
-#if !defined (__OS2__)
#define vlc_assert_locked(m) vlc_mutex_assert(m)
-#else
-# define vlc_assert_locked( m ) (void)m
-#endif
/*
* Logging
diff --git a/src/os2/thread.c b/src/os2/thread.c
index 1c93c70797..98a72984af 100644
--- a/src/os2/thread.c
+++ b/src/os2/thread.c
@@ -212,18 +212,19 @@ void vlc_mutex_lock (vlc_mutex_t *p_mutex)
p_mutex->locked = true;
vlc_mutex_unlock (&super_mutex);
vlc_restorecancel (canc);
- return;
}
+ else
+ DosRequestMutexSem(p_mutex->hmtx, SEM_INDEFINITE_WAIT);
- DosRequestMutexSem(p_mutex->hmtx, SEM_INDEFINITE_WAIT);
+ 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;
-
assert (p_mutex != &super_mutex); /* this one cannot be static */
vlc_mutex_lock (&super_mutex);
if (!p_mutex->locked)
@@ -231,11 +232,17 @@ int vlc_mutex_trylock (vlc_mutex_t *p_mutex)
p_mutex->locked = true;
ret = 0;
}
+ else
+ ret = EBUSY;
vlc_mutex_unlock (&super_mutex);
- return ret;
}
+ else
+ ret = DosRequestMutexSem( p_mutex->hmtx, 0 ) ? EBUSY : 0;
+
+ if (ret == 0)
+ vlc_mutex_mark(p_mutex);
- return DosRequestMutexSem( p_mutex->hmtx, 0 ) ? EBUSY : 0;
+ return ret;
}
void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
@@ -250,10 +257,11 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
if (p_mutex->contention)
vlc_cond_broadcast (&super_variable);
vlc_mutex_unlock (&super_mutex);
- return;
}
+ else
+ DosReleaseMutexSem( p_mutex->hmtx );
- DosReleaseMutexSem( p_mutex->hmtx );
+ vlc_mutex_unmark(p_mutex);
}
/*** Condition variables ***/
More information about the vlc-commits
mailing list