]> git.sesse.net Git - vlc/blobdiff - include/vlc_threads_funcs.h
* ./src/misc/modules.c: p_module->psz_filename is now filled with a real
[vlc] / include / vlc_threads_funcs.h
index 1c35849576490b3c2b9b3bd6f5a91a82ba851003..86b81f2f169d633d23b545289605dc71dc178170 100644 (file)
@@ -3,7 +3,7 @@
  * This header provides a portable threads implementation.
  *****************************************************************************
  * Copyright (C) 1999, 2002 VideoLAN
- * $Id: vlc_threads_funcs.h,v 1.2 2002/08/30 12:23:23 sam Exp $
+ * $Id: vlc_threads_funcs.h,v 1.9 2002/11/11 14:39:11 sam Exp $
  *
  * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
  *          Samuel Hocevar <sam@via.ecp.fr>
@@ -76,6 +76,10 @@ static inline int __vlc_mutex_lock( char * psz_file, int i_line,
 #elif defined( ST_INIT_IN_ST_H )
     i_result = st_mutex_lock( p_mutex->mutex );
 
+#elif defined( UNDER_CE )
+    EnterCriticalSection( &p_mutex->csection );
+    return 0;
+
 #elif defined( WIN32 )
     if( p_mutex->mutex )
     {
@@ -143,6 +147,10 @@ static inline int __vlc_mutex_unlock( char * psz_file, int i_line,
 #elif defined( ST_INIT_IN_ST_H )
     i_result = st_mutex_unlock( p_mutex->mutex );
 
+#elif defined( UNDER_CE )
+    LeaveCriticalSection( &p_mutex->csection );
+    return 0;
+
 #elif defined( WIN32 )
     if( p_mutex->mutex )
     {
@@ -224,6 +232,10 @@ static inline int __vlc_cond_signal( char * psz_file, int i_line,
 #elif defined( ST_INIT_IN_ST_H )
     i_result = st_cond_signal( p_condvar->cond );
 
+#elif defined( UNDER_CE )
+    PulseEvent( p_condvar->event );
+    return 0;
+
 #elif defined( WIN32 )
     /* Release one waiting thread if one is available. */
     /* For this trick to work properly, the vlc_cond_signal must be surrounded
@@ -315,6 +327,7 @@ static inline int __vlc_cond_signal( char * psz_file, int i_line,
                 return 0;
             }
         }
+        i_result = 0;
     }
 #endif
 
@@ -354,7 +367,19 @@ static inline int __vlc_cond_broadcast( char * psz_file, int i_line,
 #elif defined( ST_INIT_IN_ST_H )
     i_result = st_cond_broadcast( p_condvar->cond );
 
+#elif defined( UNDER_CE )
+    int i;
+
+    /* Release all waiting threads. */
+    for( i = p_condvar->i_waiting_threads; i > 0; i-- )
+    {
+        PulseEvent( p_condvar->event );
+    }
+    return 0;
+
 #elif defined( WIN32 )
+    int i;
+
     /* Release all waiting threads. */
     if( !p_condvar->semaphore )
     {
@@ -448,6 +473,7 @@ static inline int __vlc_cond_broadcast( char * psz_file, int i_line,
                 return 0;
             }
         }
+        i_result = 0;
     }
 #endif
 
@@ -483,13 +509,24 @@ static inline int __vlc_cond_wait( char * psz_file, int i_line,
     i_result = st_cond_wait( p_condvar->cond );
     st_mutex_lock( p_mutex->mutex );
 
+#elif defined( UNDER_CE )
+    p_condvar->i_waiting_threads++;
+    LeaveCriticalSection( &p_mutex->csection );
+    WaitForSingleObject( p_condvar->event, INFINITE );
+    p_condvar->i_waiting_threads--;
+
+    /* Reacquire the mutex before returning. */
+    vlc_mutex_lock( p_mutex );
+
+    return 0;
+
 #elif defined( WIN32 )
     if( !p_condvar->semaphore )
     {
         /* Increase our wait count */
         p_condvar->i_waiting_threads++;
 
-        if( p_condvar->SignalObjectAndWait && p_mutex->mutex )
+        if( p_mutex->mutex )
         {
             /* It is only possible to atomically release the mutex and
              * initiate the waiting on WinNT/2K/XP. Win9x doesn't have