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

Win32: Simplify mutex

parent 6ed74223
...@@ -128,10 +128,7 @@ typedef struct ...@@ -128,10 +128,7 @@ typedef struct
typedef BOOL (WINAPI *SIGNALOBJECTANDWAIT) ( HANDLE, HANDLE, DWORD, BOOL ); typedef BOOL (WINAPI *SIGNALOBJECTANDWAIT) ( HANDLE, HANDLE, DWORD, BOOL );
typedef struct typedef HANDLE vlc_mutex_t;
{
HANDLE mutex;
} vlc_mutex_t;
typedef struct typedef struct
{ {
......
...@@ -101,7 +101,7 @@ static inline void __vlc_mutex_lock( const char * psz_file, int i_line, ...@@ -101,7 +101,7 @@ static inline void __vlc_mutex_lock( const char * psz_file, int i_line,
#elif defined( WIN32 ) #elif defined( WIN32 )
VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
WaitForSingleObject( p_mutex->mutex, INFINITE ); WaitForSingleObject( *p_mutex, INFINITE );
#elif defined( HAVE_KERNEL_SCHEDULER_H ) #elif defined( HAVE_KERNEL_SCHEDULER_H )
acquire_sem( p_mutex->lock ); acquire_sem( p_mutex->lock );
...@@ -136,7 +136,7 @@ static inline void __vlc_mutex_unlock( const char * psz_file, int i_line, ...@@ -136,7 +136,7 @@ static inline void __vlc_mutex_unlock( const char * psz_file, int i_line,
#elif defined( WIN32 ) #elif defined( WIN32 )
VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
ReleaseMutex( p_mutex->mutex ); ReleaseMutex( *p_mutex );
#elif defined( HAVE_KERNEL_SCHEDULER_H ) #elif defined( HAVE_KERNEL_SCHEDULER_H )
release_sem( p_mutex->lock ); release_sem( p_mutex->lock );
...@@ -232,7 +232,7 @@ static inline void __vlc_cond_wait( const char * psz_file, int i_line, ...@@ -232,7 +232,7 @@ static inline void __vlc_cond_wait( const char * psz_file, int i_line,
/* Increase our wait count */ /* Increase our wait count */
p_condvar->i_waiting_threads++; p_condvar->i_waiting_threads++;
SignalObjectAndWait( p_mutex->mutex, p_condvar->event, INFINITE, FALSE ); SignalObjectAndWait( *p_mutex, p_condvar->event, INFINITE, FALSE );
p_condvar->i_waiting_threads--; p_condvar->i_waiting_threads--;
/* Reacquire the mutex before returning. */ /* Reacquire the mutex before returning. */
...@@ -299,7 +299,7 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line, ...@@ -299,7 +299,7 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
/* Increase our wait count */ /* Increase our wait count */
p_condvar->i_waiting_threads++; p_condvar->i_waiting_threads++;
result = SignalObjectAndWait( p_mutex->mutex, p_condvar->event, result = SignalObjectAndWait( *p_mutex, p_condvar->event,
delay_ms, FALSE ); delay_ms, FALSE );
p_condvar->i_waiting_threads--; p_condvar->i_waiting_threads--;
......
...@@ -229,8 +229,8 @@ int __vlc_mutex_init( vlc_mutex_t *p_mutex ) ...@@ -229,8 +229,8 @@ int __vlc_mutex_init( vlc_mutex_t *p_mutex )
return 0; return 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
p_mutex->mutex = CreateMutex( 0, FALSE, 0 ); *p_mutex = CreateMutex( 0, FALSE, 0 );
return ( p_mutex->mutex != NULL ? 0 : 1 ); return (*p_mutex != NULL) ? 0 : ENOMEM;
#elif defined( HAVE_KERNEL_SCHEDULER_H ) #elif defined( HAVE_KERNEL_SCHEDULER_H )
/* check the arguments and whether it's already been initialized */ /* check the arguments and whether it's already been initialized */
...@@ -280,8 +280,8 @@ int __vlc_mutex_init_recursive( vlc_mutex_t *p_mutex ) ...@@ -280,8 +280,8 @@ int __vlc_mutex_init_recursive( vlc_mutex_t *p_mutex )
{ {
#if defined( WIN32 ) #if defined( WIN32 )
/* Create mutex returns a recursive mutex */ /* Create mutex returns a recursive mutex */
p_mutex->mutex = CreateMutex( 0, FALSE, 0 ); *p_mutex = CreateMutex( 0, FALSE, 0 );
return ( p_mutex->mutex != NULL ? 0 : 1 ); return (*p_mutex != NULL) ? 0 : ENOMEM;
#elif defined( LIBVLC_USE_PTHREAD ) #elif defined( LIBVLC_USE_PTHREAD )
pthread_mutexattr_t attr; pthread_mutexattr_t attr;
int i_result; int i_result;
...@@ -318,7 +318,7 @@ void __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mute ...@@ -318,7 +318,7 @@ void __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mute
#elif defined( WIN32 ) #elif defined( WIN32 )
VLC_UNUSED( psz_file); VLC_UNUSED( i_line ); VLC_UNUSED( psz_file); VLC_UNUSED( i_line );
CloseHandle( p_mutex->mutex ); CloseHandle( *p_mutex );
#elif defined( HAVE_KERNEL_SCHEDULER_H ) #elif defined( HAVE_KERNEL_SCHEDULER_H )
if( p_mutex->init == 9999 ) if( p_mutex->init == 9999 )
...@@ -417,7 +417,7 @@ int __vlc_threadvar_create( vlc_threadvar_t *p_tls ) ...@@ -417,7 +417,7 @@ int __vlc_threadvar_create( vlc_threadvar_t *p_tls )
#if defined( HAVE_KERNEL_SCHEDULER_H ) #if defined( HAVE_KERNEL_SCHEDULER_H )
# error Unimplemented! # error Unimplemented!
#elif defined( UNDER_CE ) || defined( WIN32 ) #elif defined( UNDER_CE )
#elif defined( WIN32 ) #elif defined( WIN32 )
*p_tls = TlsAlloc(); *p_tls = TlsAlloc();
i_ret = (*p_tls == INVALID_HANDLE_VALUE) ? EAGAIN : 0; i_ret = (*p_tls == INVALID_HANDLE_VALUE) ? EAGAIN : 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