+#elif defined( ST_INIT_IN_ST_H )
+ int i_ret;
+
+ st_mutex_unlock( *p_mutex );
+ i_ret = st_cond_wait( *p_condvar );
+ st_mutex_lock( *p_mutex );
+
+ return i_ret;
+
+#elif defined( WIN32 )
+ /* The ideal would be to use a function which atomically releases the
+ * mutex and initiate the waiting.
+ * Unfortunately only the SignalObjectAndWait function does this and it's
+ * only supported on WinNT/2K, furthermore it cannot take multiple
+ * events as parameters.
+ *
+ * The solution we use should however fulfill all our needs (even though
+ * it is not a correct pthreads implementation)
+ */
+ int i_result;
+
+ p_condvar->i_waiting_threads ++;
+
+ if( p_mutex->mutex )
+ {
+ p_main_sys->SignalObjectAndWait( p_mutex->mutex, p_condvar->signal,
+ INFINITE, FALSE );
+ }
+ else
+ {
+ /* Release the mutex */
+ vlc_mutex_unlock( p_mutex );
+ i_result = WaitForSingleObject( p_condvar->signal, INFINITE);
+ p_condvar->i_waiting_threads --;
+ }
+
+ /* Reacquire the mutex before returning. */
+ vlc_mutex_lock( p_mutex );
+
+ return( i_result == WAIT_FAILED );
+