Commit d7e6fd9e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Win32: fix vlc_cond_timedwait as well

parent 9219a602
...@@ -386,20 +386,14 @@ static inline void __vlc_cond_wait( const char * psz_file, int i_line, ...@@ -386,20 +386,14 @@ static inline void __vlc_cond_wait( const char * psz_file, int i_line,
vlc_mutex_lock( p_mutex ); vlc_mutex_lock( p_mutex );
#elif defined( WIN32 ) #elif defined( WIN32 )
DWORD result;
do do
{
vlc_testcancel (); vlc_testcancel ();
result = SignalObjectAndWait (*p_mutex, *p_condvar, INFINITE, TRUE); while (SignalObjectAndWait (*p_mutex, *p_condvar, INFINITE, TRUE)
} == WAIT_IO_COMPLETION);
while (result == WAIT_IO_COMPLETION);
/* Reacquire the mutex before returning. */ /* Reacquire the mutex before returning. */
vlc_mutex_lock( p_mutex ); vlc_mutex_lock( p_mutex );
vlc_testcancel ();
(void)psz_file; (void)i_line; (void)psz_file; (void)i_line;
#endif #endif
...@@ -445,25 +439,25 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line, ...@@ -445,25 +439,25 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
return (result == WAIT_TIMEOUT) ? ETIMEDOUT : 0; return (result == WAIT_TIMEOUT) ? ETIMEDOUT : 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
mtime_t total; DWORD result;
DWORD result = WAIT_TIMEOUT;
(void)psz_file; (void)i_line; (void)psz_file; (void)i_line;
vlc_testcancel (); do
while ((total = (deadline - mdate ()) > 0))
{ {
vlc_testcancel ();
mtime_t total = deadline - mdate ();
if (total <= 0)
break;
DWORD delay = (total > 0x7fffffff) ? 0x7fffffff : total; DWORD delay = (total > 0x7fffffff) ? 0x7fffffff : total;
result = SignalObjectAndWait( *p_mutex, *p_condvar, result = SignalObjectAndWait (*p_mutex, *p_condvar, delay, TRUE);
delay, TRUE ); }
while (result == WAIT_IO_COMPLETION);
/* Reacquire the mutex before return/cancel. */ /* Reacquire the mutex before return/cancel. */
vlc_mutex_lock (p_mutex); vlc_mutex_lock (p_mutex);
if (result == WAIT_OBJECT_0) return (result == WAIT_OBJECT_0) ? 0 : ETIMEDOUT;
return 0; /* Condition signaled! */
vlc_testcancel ();
}
return ETIMEDOUT;
#endif #endif
} }
......
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