Commit 14c1430d authored by Rémi Denis-Courmont's avatar 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.
parent be75acdf
...@@ -212,8 +212,9 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex) ...@@ -212,8 +212,9 @@ void vlc_mutex_unlock (vlc_mutex_t *p_mutex)
/*** Condition variables ***/ /*** Condition variables ***/
enum enum
{ {
CLOCK_REALTIME=0, /* must be zero for VLC_STATIC_COND */ CLOCK_STATIC=0, /* must be zero for VLC_STATIC_COND */
CLOCK_MONOTONIC, CLOCK_MONOTONIC,
CLOCK_REALTIME,
}; };
static void vlc_cond_init_common (vlc_cond_t *p_condvar, unsigned clock) 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) ...@@ -242,7 +243,7 @@ void vlc_cond_destroy (vlc_cond_t *p_condvar)
void vlc_cond_signal (vlc_cond_t *p_condvar) void vlc_cond_signal (vlc_cond_t *p_condvar)
{ {
if (!p_condvar->handle) if (!p_condvar->clock)
return; return;
/* This is suboptimal but works. */ /* This is suboptimal but works. */
...@@ -251,7 +252,7 @@ void vlc_cond_signal (vlc_cond_t *p_condvar) ...@@ -251,7 +252,7 @@ void vlc_cond_signal (vlc_cond_t *p_condvar)
void vlc_cond_broadcast (vlc_cond_t *p_condvar) void vlc_cond_broadcast (vlc_cond_t *p_condvar)
{ {
if (!p_condvar->handle) if (!p_condvar->clock)
return; return;
/* Wake all threads up (as the event HANDLE has manual reset) */ /* 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) ...@@ -262,7 +263,7 @@ void vlc_cond_wait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex)
{ {
DWORD result; DWORD result;
if (!p_condvar->handle) if (!p_condvar->clock)
{ /* FIXME FIXME FIXME */ { /* FIXME FIXME FIXME */
msleep (50000); msleep (50000);
return; return;
...@@ -285,12 +286,6 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex, ...@@ -285,12 +286,6 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
{ {
DWORD result; DWORD result;
if (!p_condvar->handle)
{ /* FIXME FIXME FIXME */
msleep (50000);
return 0;
}
do do
{ {
vlc_testcancel (); vlc_testcancel ();
...@@ -298,13 +293,17 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex, ...@@ -298,13 +293,17 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
mtime_t total; mtime_t total;
switch (p_condvar->clock) switch (p_condvar->clock)
{ {
case CLOCK_MONOTONIC:
total = mdate();
break;
case CLOCK_REALTIME: /* FIXME? sub-second precision */ case CLOCK_REALTIME: /* FIXME? sub-second precision */
total = CLOCK_FREQ * time (NULL); total = CLOCK_FREQ * time (NULL);
break; break;
default: default:
assert (p_condvar->clock == CLOCK_MONOTONIC); assert (!p_condvar->clock);
total = mdate(); /* FIXME FIXME FIXME */
break; msleep (50000);
return 0;
} }
total = (deadline - total) / 1000; total = (deadline - total) / 1000;
if( total < 0 ) if( total < 0 )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment