+ modules/misc/freetype.c: fixed a couple of typos

+ *threads*, src/libvlc.h:
   test HAVE_KERNEL_SCHEDULER_H before PTHREAD_COND_T_IN_PTHREAD_H
   for now because Zeta now has a pthread implementation but it's doesn't
   seem to be (enough) POSIX compliant atm.
This commit is contained in:
Eric Petit 2003-11-22 00:41:07 +00:00
parent 09d997200c
commit eae53f7c78
5 changed files with 217 additions and 210 deletions

View File

@ -3,7 +3,7 @@
* This header provides portable declarations for mutexes & conditions
*****************************************************************************
* Copyright (C) 1999, 2002 VideoLAN
* $Id: vlc_threads.h,v 1.35 2003/11/07 19:30:28 massiot Exp $
* $Id: vlc_threads.h,v 1.36 2003/11/22 00:41:07 titer Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
@ -42,6 +42,11 @@
#elif defined( WIN32 )
# include <process.h> /* Win32 API */
#elif defined( HAVE_KERNEL_SCHEDULER_H ) /* BeOS */
# include <kernel/OS.h>
# include <kernel/scheduler.h>
# include <byteorder.h>
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) /* pthreads (like Linux & BSD) */
# include <pthread.h>
# ifdef DEBUG
@ -54,11 +59,6 @@
#elif defined( HAVE_CTHREADS_H ) /* GNUMach */
# include <cthreads.h>
#elif defined( HAVE_KERNEL_SCHEDULER_H ) /* BeOS */
# include <kernel/OS.h>
# include <kernel/scheduler.h>
# include <byteorder.h>
#else
# error no threads available on your system !
@ -76,6 +76,13 @@
# define VLC_THREAD_PRIORITY_VIDEO (-47)
# define VLC_THREAD_PRIORITY_OUTPUT 37
#elif defined(SYS_BEOS)
# define VLC_THREAD_PRIORITY_LOW 5
# define VLC_THREAD_PRIORITY_INPUT 10
# define VLC_THREAD_PRIORITY_AUDIO 10
# define VLC_THREAD_PRIORITY_VIDEO 5
# define VLC_THREAD_PRIORITY_OUTPUT 15
#elif defined(PTHREAD_COND_T_IN_PTHREAD_H)
# define VLC_THREAD_PRIORITY_LOW 0
# define VLC_THREAD_PRIORITY_INPUT 20
@ -97,13 +104,6 @@
# define VLC_THREAD_PRIORITY_HIGHEST \
(IS_WINNT ? THREAD_PRIORITY_TIME_CRITICAL : 0)
#elif defined(SYS_BEOS)
# define VLC_THREAD_PRIORITY_LOW 5
# define VLC_THREAD_PRIORITY_INPUT 10
# define VLC_THREAD_PRIORITY_AUDIO 10
# define VLC_THREAD_PRIORITY_VIDEO 5
# define VLC_THREAD_PRIORITY_OUTPUT 15
#else
# define VLC_THREAD_PRIORITY_LOW 0
# define VLC_THREAD_PRIORITY_INPUT 0
@ -172,6 +172,29 @@ typedef struct
vlc_object_t * p_this;
} vlc_cond_t;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
/* This is the BeOS implementation of the vlc threads, note that the mutex is
* not a real mutex and the cond_var is not like a pthread cond_var but it is
* enough for what wee need */
typedef thread_id vlc_thread_t;
typedef struct
{
int32_t init;
sem_id lock;
vlc_object_t * p_this;
} vlc_mutex_t;
typedef struct
{
int32_t init;
thread_id thread;
vlc_object_t * p_this;
} vlc_cond_t;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
typedef pthread_t vlc_thread_t;
typedef struct
@ -211,28 +234,5 @@ typedef struct
vlc_object_t * p_this;
} vlc_cond_t;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
/* This is the BeOS implementation of the vlc threads, note that the mutex is
* not a real mutex and the cond_var is not like a pthread cond_var but it is
* enough for what wee need */
typedef thread_id vlc_thread_t;
typedef struct
{
int32_t init;
sem_id lock;
vlc_object_t * p_this;
} vlc_mutex_t;
typedef struct
{
int32_t init;
thread_id thread;
vlc_object_t * p_this;
} vlc_cond_t;
#endif

View File

@ -3,7 +3,7 @@
* This header provides a portable threads implementation.
*****************************************************************************
* Copyright (C) 1999, 2002 VideoLAN
* $Id: vlc_threads_funcs.h,v 1.15 2003/03/02 01:35:30 gbazin Exp $
* $Id: vlc_threads_funcs.h,v 1.16 2003/11/22 00:41:07 titer Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
@ -93,18 +93,6 @@ static inline int __vlc_mutex_lock( char * psz_file, int i_line,
}
i_result = 0;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_mutex_lock( &p_mutex->mutex );
if ( i_result )
{
i_thread = (int)pthread_self();
psz_error = strerror(i_result);
}
#elif defined( HAVE_CTHREADS_H )
mutex_lock( p_mutex->mutex );
i_result = 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
if( p_mutex == NULL )
{
@ -118,6 +106,19 @@ static inline int __vlc_mutex_lock( char * psz_file, int i_line,
{
i_result = acquire_sem( p_mutex->lock );
}
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_mutex_lock( &p_mutex->mutex );
if ( i_result )
{
i_thread = (int)pthread_self();
psz_error = strerror(i_result);
}
#elif defined( HAVE_CTHREADS_H )
mutex_lock( p_mutex->mutex );
i_result = 0;
#endif
if( i_result )
@ -164,18 +165,6 @@ static inline int __vlc_mutex_unlock( char * psz_file, int i_line,
}
i_result = 0;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_mutex_unlock( &p_mutex->mutex );
if ( i_result )
{
i_thread = (int)pthread_self();
psz_error = strerror(i_result);
}
#elif defined( HAVE_CTHREADS_H )
mutex_unlock( p_mutex );
i_result = 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
if( p_mutex == NULL )
{
@ -190,6 +179,19 @@ static inline int __vlc_mutex_unlock( char * psz_file, int i_line,
release_sem( p_mutex->lock );
return B_OK;
}
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_mutex_unlock( &p_mutex->mutex );
if ( i_result )
{
i_thread = (int)pthread_self();
psz_error = strerror(i_result);
}
#elif defined( HAVE_CTHREADS_H )
mutex_unlock( p_mutex );
i_result = 0;
#endif
if( i_result )
@ -279,22 +281,6 @@ static inline int __vlc_cond_signal( char * psz_file, int i_line,
}
i_result = 0;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_cond_signal( &p_condvar->cond );
if ( i_result )
{
i_thread = (int)pthread_self();
psz_error = strerror(i_result);
}
#elif defined( HAVE_CTHREADS_H )
/* condition_signal() */
if ( p_condvar->queue.head || p_condvar->implications )
{
cond_signal( (condition_t)p_condvar );
}
i_result = 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
if( p_condvar == NULL )
{
@ -331,6 +317,23 @@ static inline int __vlc_cond_signal( char * psz_file, int i_line,
}
i_result = 0;
}
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_cond_signal( &p_condvar->cond );
if ( i_result )
{
i_thread = (int)pthread_self();
psz_error = strerror(i_result);
}
#elif defined( HAVE_CTHREADS_H )
/* condition_signal() */
if ( p_condvar->queue.head || p_condvar->implications )
{
cond_signal( (condition_t)p_condvar );
}
i_result = 0;
#endif
if( i_result )
@ -425,22 +428,6 @@ static inline int __vlc_cond_broadcast( char * psz_file, int i_line,
}
i_result = 0;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_cond_broadcast( &p_condvar->cond );
if ( i_result )
{
i_thread = (int)pthread_self();
psz_error = strerror(i_result);
}
#elif defined( HAVE_CTHREADS_H )
/* condition_signal() */
if ( p_condvar->queue.head || p_condvar->implications )
{
cond_signal( (condition_t)p_condvar );
}
i_result = 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
if( p_condvar == NULL )
{
@ -477,6 +464,23 @@ static inline int __vlc_cond_broadcast( char * psz_file, int i_line,
}
i_result = 0;
}
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_cond_broadcast( &p_condvar->cond );
if ( i_result )
{
i_thread = (int)pthread_self();
psz_error = strerror(i_result);
}
#elif defined( HAVE_CTHREADS_H )
/* condition_signal() */
if ( p_condvar->queue.head || p_condvar->implications )
{
cond_signal( (condition_t)p_condvar );
}
i_result = 0;
#endif
if( i_result )
@ -599,6 +603,31 @@ static inline int __vlc_cond_wait( char * psz_file, int i_line,
i_result = 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
if( p_condvar == NULL )
{
i_result = B_BAD_VALUE;
}
else if( p_mutex == NULL )
{
i_result = B_BAD_VALUE;
}
else if( p_condvar->init < 2000 )
{
i_result = B_NO_INIT;
}
/* The p_condvar->thread var is initialized before the unlock because
* it enables to identify when the thread is interrupted beetwen the
* unlock line and the suspend_thread line */
p_condvar->thread = find_thread( NULL );
vlc_mutex_unlock( p_mutex );
suspend_thread( p_condvar->thread );
p_condvar->thread = -1;
vlc_mutex_lock( p_mutex );
i_result = 0;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
# ifdef DEBUG
@ -638,31 +667,6 @@ static inline int __vlc_cond_wait( char * psz_file, int i_line,
condition_wait( (condition_t)p_condvar, (mutex_t)p_mutex );
i_result = 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
if( p_condvar == NULL )
{
i_result = B_BAD_VALUE;
}
else if( p_mutex == NULL )
{
i_result = B_BAD_VALUE;
}
else if( p_condvar->init < 2000 )
{
i_result = B_NO_INIT;
}
/* The p_condvar->thread var is initialized before the unlock because
* it enables to identify when the thread is interrupted beetwen the
* unlock line and the suspend_thread line */
p_condvar->thread = find_thread( NULL );
vlc_mutex_unlock( p_mutex );
suspend_thread( p_condvar->thread );
p_condvar->thread = -1;
vlc_mutex_lock( p_mutex );
i_result = 0;
#endif
if( i_result )

View File

@ -2,7 +2,7 @@
* freetype.c : Put text on the video, using freetype2
*****************************************************************************
* Copyright (C) 2002, 2003 VideoLAN
* $Id: freetype.c,v 1.34 2003/11/19 13:25:48 hartman Exp $
* $Id: freetype.c,v 1.35 2003/11/22 00:41:07 titer Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
@ -94,7 +94,7 @@ static line_desc_t *NewLine( byte_t * );
#define FONTSIZER_TEXT N_("Font size")
#define FONTSIZER_LONGTEXT N_("The size of the fonts used by the osd module" )
static int *pi_sizes[] = { 20, 18, 16, 12, 6 };
static int pi_sizes[] = { 20, 18, 16, 12, 6 };
static char *ppsz_sizes_text[] = { N_("Smaller"), N_("Small"), N_("Normal"),
N_("Large"), N_("Larger") };

View File

@ -2,7 +2,7 @@
* libvlc.h: main libvlc header
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.h,v 1.107 2003/11/16 21:07:31 gbazin Exp $
* $Id: libvlc.h,v 1.108 2003/11/22 00:41:07 titer Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
@ -749,7 +749,7 @@ vlc_module_begin();
add_module( "access", "access", NULL, NULL, ACCESS_TEXT, ACCESS_LONGTEXT, VLC_TRUE );
add_module( "demux", "demux", NULL, NULL, DEMUX_TEXT, DEMUX_LONGTEXT, VLC_TRUE );
#if !defined(SYS_DARWIN) && defined(PTHREAD_COND_T_IN_PTHREAD_H)
#if !defined(SYS_DARWIN) && !defined(SYS_BEOS) && defined(PTHREAD_COND_T_IN_PTHREAD_H)
add_bool( "rt-priority", 0, NULL, RT_PRIORITY_TEXT, RT_PRIORITY_LONGTEXT, VLC_TRUE );
#endif

View File

@ -2,7 +2,7 @@
* threads.c : threads implementation for the VideoLAN client
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002, 2003 VideoLAN
* $Id: threads.c,v 1.43 2003/11/07 19:30:28 massiot Exp $
* $Id: threads.c,v 1.44 2003/11/22 00:41:07 titer Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
@ -41,10 +41,10 @@ static volatile int i_initializations = 0;
#elif defined( ST_INIT_IN_ST_H )
#elif defined( UNDER_CE )
#elif defined( WIN32 )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER;
#elif defined( HAVE_CTHREADS_H )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#endif
/*****************************************************************************
@ -81,10 +81,10 @@ int __vlc_threads_init( vlc_object_t *p_this )
#elif defined( UNDER_CE )
#elif defined( WIN32 )
HINSTANCE hInstLib;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
pthread_mutex_lock( &once_mutex );
#elif defined( HAVE_CTHREADS_H )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#endif
if( i_status == VLC_THREADS_UNINITIALIZED )
@ -124,9 +124,9 @@ int __vlc_threads_init( vlc_object_t *p_this )
p_libvlc->b_fast_mutex = 0;
p_libvlc->i_win9x_cv = 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
#elif defined( HAVE_CTHREADS_H )
#elif defined( HAVE_KERNEL_SCHEDULER_H )
#endif
vlc_object_create( p_libvlc, VLC_OBJECT_ROOT );
@ -157,12 +157,12 @@ int __vlc_threads_init( vlc_object_t *p_this )
while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
#elif defined( WIN32 )
while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
#elif defined( HAVE_KERNEL_SCHEDULER_H )
while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
pthread_mutex_unlock( &once_mutex );
#elif defined( HAVE_CTHREADS_H )
while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
#elif defined( HAVE_KERNEL_SCHEDULER_H )
while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
#endif
if( i_status != VLC_THREADS_READY )
@ -197,6 +197,9 @@ int __vlc_threads_end( vlc_object_t *p_this )
#elif defined( WIN32 )
i_initializations--;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
i_initializations--;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
pthread_mutex_lock( &once_mutex );
i_initializations--;
@ -205,9 +208,6 @@ int __vlc_threads_end( vlc_object_t *p_this )
#elif defined( HAVE_CTHREADS_H )
i_initializations--;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
i_initializations--;
#endif
return VLC_SUCCESS;
}
@ -249,26 +249,6 @@ int __vlc_mutex_init( vlc_object_t *p_this, vlc_mutex_t *p_mutex )
return 0;
}
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
# if defined(DEBUG) && defined(SYS_LINUX)
{
/* Create error-checking mutex to detect problems more easily. */
pthread_mutexattr_t attr;
int i_result;
pthread_mutexattr_init( &attr );
pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
pthread_mutexattr_destroy( &attr );
return( i_result );
}
# endif
return pthread_mutex_init( &p_mutex->mutex, NULL );
#elif defined( HAVE_CTHREADS_H )
mutex_init( p_mutex );
return 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
/* check the arguments and whether it's already been initialized */
if( p_mutex == NULL )
@ -290,6 +270,26 @@ int __vlc_mutex_init( vlc_object_t *p_this, vlc_mutex_t *p_mutex )
p_mutex->init = 9999;
return B_OK;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
# if defined(DEBUG) && defined(SYS_LINUX)
{
/* Create error-checking mutex to detect problems more easily. */
pthread_mutexattr_t attr;
int i_result;
pthread_mutexattr_init( &attr );
pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
pthread_mutexattr_destroy( &attr );
return( i_result );
}
# endif
return pthread_mutex_init( &p_mutex->mutex, NULL );
#elif defined( HAVE_CTHREADS_H )
mutex_init( p_mutex );
return 0;
#endif
}
@ -324,6 +324,15 @@ int __vlc_mutex_destroy( char * psz_file, int i_line, vlc_mutex_t *p_mutex )
}
return 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
if( p_mutex->init == 9999 )
{
delete_sem( p_mutex->lock );
}
p_mutex->init = 0;
return B_OK;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_mutex_destroy( &p_mutex->mutex );
if ( i_result )
@ -335,14 +344,6 @@ int __vlc_mutex_destroy( char * psz_file, int i_line, vlc_mutex_t *p_mutex )
#elif defined( HAVE_CTHREADS_H )
return 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
if( p_mutex->init == 9999 )
{
delete_sem( p_mutex->lock );
}
p_mutex->init = 0;
return B_OK;
#endif
if( i_result )
@ -418,18 +419,6 @@ int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar )
return !p_condvar->semaphore || !p_condvar->event;
}
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
return pthread_cond_init( &p_condvar->cond, NULL );
#elif defined( HAVE_CTHREADS_H )
/* condition_init() */
spin_lock_init( &p_condvar->lock );
cthread_queue_init( &p_condvar->queue );
p_condvar->name = 0;
p_condvar->implications = 0;
return 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
if( !p_condvar )
{
@ -444,6 +433,19 @@ int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar )
p_condvar->thread = -1;
p_condvar->init = 9999;
return 0;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
return pthread_cond_init( &p_condvar->cond, NULL );
#elif defined( HAVE_CTHREADS_H )
/* condition_init() */
spin_lock_init( &p_condvar->lock );
cthread_queue_init( &p_condvar->queue );
p_condvar->name = 0;
p_condvar->implications = 0;
return 0;
#endif
}
@ -473,6 +475,10 @@ int __vlc_cond_destroy( char * psz_file, int i_line, vlc_cond_t *p_condvar )
i_result = !CloseHandle( p_condvar->event )
|| !CloseHandle( p_condvar->semaphore );
#elif defined( HAVE_KERNEL_SCHEDULER_H )
p_condvar->init = 0;
return 0;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_result = pthread_cond_destroy( &p_condvar->cond );
if ( i_result )
@ -484,9 +490,6 @@ int __vlc_cond_destroy( char * psz_file, int i_line, vlc_cond_t *p_condvar )
#elif defined( HAVE_CTHREADS_H )
return 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
p_condvar->init = 0;
return 0;
#endif
if( i_result )
@ -549,6 +552,11 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
i_ret = ( p_this->thread_id ? 0 : 1 );
#elif defined( HAVE_KERNEL_SCHEDULER_H )
p_this->thread_id = spawn_thread( (thread_func)func, psz_name,
i_priority, p_data );
i_ret = resume_thread( p_this->thread_id );
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_ret = pthread_create( &p_this->thread_id, NULL, func, p_data );
@ -588,11 +596,6 @@ int __vlc_thread_create( vlc_object_t *p_this, char * psz_file, int i_line,
p_this->thread_id = cthread_fork( (cthread_fn_t)func, (any_t)p_data );
i_ret = 0;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
p_this->thread_id = spawn_thread( (thread_func)func, psz_name,
i_priority, p_data );
i_ret = resume_thread( p_this->thread_id );
#endif
if( i_ret == 0 )
@ -703,6 +706,10 @@ void __vlc_thread_join( vlc_object_t *p_this, char * psz_file, int i_line )
#elif defined( WIN32 )
WaitForSingleObject( p_this->thread_id, INFINITE );
#elif defined( HAVE_KERNEL_SCHEDULER_H )
int32_t exit_value;
wait_for_thread( p_this->thread_id, &exit_value );
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
i_ret = pthread_join( p_this->thread_id, NULL );
@ -710,10 +717,6 @@ void __vlc_thread_join( vlc_object_t *p_this, char * psz_file, int i_line )
cthread_join( p_this->thread_id );
i_ret = 1;
#elif defined( HAVE_KERNEL_SCHEDULER_H )
int32_t exit_value;
wait_for_thread( p_this->thread_id, &exit_value );
#endif
if( i_ret )