#include <vlc/vlc.h>
#include "libvlc.h"
+#include <assert.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#define VLC_THREADS_UNINITIALIZED 0
#define VLC_THREADS_PENDING 1
*****************************************************************************/
int __vlc_mutex_init( vlc_object_t *p_this, vlc_mutex_t *p_mutex )
{
+ assert( p_this );
p_mutex->p_this = p_this;
#if defined( PTH_INIT_IN_PTH_H )
return B_OK;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
-# if defined(DEBUG) && defined(SYS_LINUX)
+# if defined(DEBUG)
+# if defined(SYS_LINUX)
{
/* Create error-checking mutex to detect problems more easily. */
pthread_mutexattr_t attr;
pthread_mutexattr_destroy( &attr );
return( i_result );
}
+# else
+ {
+ /* Create error-checking mutex to detect problems more easily. */
+ pthread_mutexattr_t attr;
+ int i_result;
+
+ pthread_mutexattr_init( &attr );
+ pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_ERRORCHECK );
+ i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
+ pthread_mutexattr_destroy( &attr );
+ return( i_result );
+ }
# endif
+# endif
return pthread_mutex_init( &p_mutex->mutex, NULL );
#elif defined( HAVE_CTHREADS_H )
return 0;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
- return pthread_cond_init( &p_condvar->cond, NULL );
+ pthread_condattr_t attr;
+ int ret;
+
+ ret = pthread_condattr_init (&attr);
+ if (ret)
+ return ret;
+
+# if defined (_POSIX_CLOCK_SELECTION) && (_POSIX_CLOCK_SELECTION - 0 > 0)
+ /* NOTE: This must be the same clock as the one in mtime.c */
+ pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
+# endif
+
+ ret = pthread_cond_init (&p_condvar->cond, &attr);
+ pthread_condattr_destroy (&attr);
+ return ret;
#elif defined( HAVE_CTHREADS_H )
/* condition_init() */
if( b_wait )
{
msg_Dbg( p_this, "waiting for thread completion" );
- vlc_cond_wait( &p_this->object_wait, &p_this->object_lock );
+ vlc_object_wait( p_this );
}
p_priv->b_thread = VLC_TRUE;
*****************************************************************************/
void __vlc_thread_ready( vlc_object_t *p_this )
{
- vlc_mutex_lock( &p_this->object_lock );
- vlc_cond_signal( &p_this->object_wait );
- vlc_mutex_unlock( &p_this->object_lock );
+ vlc_object_signal( p_this );
}
/*****************************************************************************