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)
/*** 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 )
......
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