[vlc-commits] Win32: use clock field to discriminate static variables
Rémi Denis-Courmont
git at videolan.org
Mon Sep 10 16:07:13 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Sep 10 17:04:05 2012 +0300| [14c1430db64d6d2636f9925782e93a953052d767] | committer: Rémi Denis-Courmont
Win32: use clock field to discriminate static variables
This avoids having to make assumptions about the layout of the
underlying condition variables in the OS.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=14c1430db64d6d2636f9925782e93a953052d767
---
src/win32/thread.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 140bd72..be8c494 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -212,8 +212,9 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
/*** Condition variables ***/
enum
{
- CLOCK_REALTIME=0, /* must be zero for VLC_STATIC_COND */
+ CLOCK_STATIC=0, /* must be zero for VLC_STATIC_COND */
CLOCK_MONOTONIC,
+ CLOCK_REALTIME,
};
static void vlc_cond_init_common (vlc_cond_t *p_condvar, unsigned clock)
@@ -242,7 +243,7 @@ void vlc_cond_destroy (vlc_cond_t *p_condvar)
void vlc_cond_signal (vlc_cond_t *p_condvar)
{
- if (!p_condvar->handle)
+ if (!p_condvar->clock)
return;
/* This is suboptimal but works. */
@@ -251,7 +252,7 @@ void vlc_cond_signal (vlc_cond_t *p_condvar)
void vlc_cond_broadcast (vlc_cond_t *p_condvar)
{
- if (!p_condvar->handle)
+ if (!p_condvar->clock)
return;
/* Wake all threads up (as the event HANDLE has manual reset) */
@@ -262,7 +263,7 @@ void vlc_cond_wait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex)
{
DWORD result;
- if (!p_condvar->handle)
+ if (!p_condvar->clock)
{ /* FIXME FIXME FIXME */
msleep (50000);
return;
@@ -285,12 +286,6 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
{
DWORD result;
- if (!p_condvar->handle)
- { /* FIXME FIXME FIXME */
- msleep (50000);
- return 0;
- }
-
do
{
vlc_testcancel ();
@@ -298,13 +293,17 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
mtime_t total;
switch (p_condvar->clock)
{
+ case CLOCK_MONOTONIC:
+ total = mdate();
+ break;
case CLOCK_REALTIME: /* FIXME? sub-second precision */
total = CLOCK_FREQ * time (NULL);
break;
default:
- assert (p_condvar->clock == CLOCK_MONOTONIC);
- total = mdate();
- break;
+ assert (!p_condvar->clock);
+ /* FIXME FIXME FIXME */
+ msleep (50000);
+ return 0;
}
total = (deadline - total) / 1000;
if( total < 0 )
More information about the vlc-commits
mailing list