Commit 248eb0b5 authored by Christophe Massiot's avatar Christophe Massiot

* Added error checking in pthread wrapper ; as a result, intf_msg.h must

now be included *before* threads.h ;
* Changed all files to include intf_msg.h before threads.h ; while I was
at it, I update the copyright notices ;
* Removed the obsolete darwin plug-in.
parent 65daff0b
......@@ -18,7 +18,6 @@ PLUGINS_DIR := ac3_adec \
alsa \
arts \
beos \
darwin \
directx \
dsp \
dummy \
......@@ -53,7 +52,6 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \
alsa/alsa \
arts/arts \
beos/beos \
darwin/darwin \
directx/directx \
dsp/dsp \
dummy/dummy \
......
This diff is collapsed.
......@@ -392,6 +392,9 @@ dnl
dnl Check the operating system
dnl
case ${target_os} in
linux*)
SYS=linux
;;
bsdi*)
SYS=bsdi
;;
......@@ -808,16 +811,6 @@ AC_ARG_ENABLE(arts,
fi
fi])
dnl
dnl Darwin module
dnl
AC_ARG_ENABLE(darwin,
[ --enable-darwin Darwin sound support (default enabled on MacOS X)],
[if test x$enable_darwin = xyes; then
PLUGINS="${PLUGINS} darwin"
LIB_DARWIN="-framework CoreAudio"
fi])
dnl
dnl MacOS X module
dnl
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.50 2001/11/25 22:52:21 gbazin Exp $
* $Id: common.h,v 1.51 2001/11/28 15:08:04 massiot Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -71,6 +71,18 @@ typedef s16 dctelem_t;
/* Video buffer types */
typedef u8 yuv_data_t;
/*****************************************************************************
* mtime_t: high precision date or time interval
*****************************************************************************
* Store an high precision date or time interval. The maximum precision is the
* micro-second, and a 64 bits integer is used to avoid any overflow (maximum
* time interval is then 292271 years, which should be length enough for any
* video). Date are stored as a time interval since a common date.
* Note that date and time intervals can be manipulated using regular arithmetic
* operators, and that no special functions are required.
*****************************************************************************/
typedef s64 mtime_t;
/*****************************************************************************
* Classes declaration
*****************************************************************************/
......@@ -230,3 +242,158 @@ struct decoder_fifo_s;
#if defined( WIN32 )
# include "common_win32.h"
#endif
/*****************************************************************************
* Plug-in stuff
*****************************************************************************/
typedef struct module_symbols_s
{
struct main_s* p_main;
struct aout_bank_s* p_aout_bank;
struct vout_bank_s* p_vout_bank;
int ( * main_GetIntVariable ) ( char *, int );
char * ( * main_GetPszVariable ) ( char *, char * );
void ( * main_PutIntVariable ) ( char *, int );
void ( * main_PutPszVariable ) ( char *, char * );
int ( * TestProgram ) ( char * );
int ( * TestMethod ) ( char *, char * );
int ( * TestCPU ) ( int );
int ( * intf_ProcessKey ) ( struct intf_thread_s *, int );
void ( * intf_AssignKey ) ( struct intf_thread_s *, int, int, int );
void ( * intf_Msg ) ( char *, ... );
void ( * intf_ErrMsg ) ( char *, ... );
void ( * intf_StatMsg ) ( char *, ... );
void ( * intf_WarnMsg ) ( int, char *, ... );
void ( * intf_WarnMsgImm ) ( int, char *, ... );
#ifdef TRACE
void ( * intf_DbgMsg ) ( char *, char *, int, char *, ... );
void ( * intf_DbgMsgImm ) ( char *, char *, int, char *, ... );
#endif
int ( * intf_PlaylistAdd ) ( struct playlist_s *, int, const char* );
int ( * intf_PlaylistDelete ) ( struct playlist_s *, int );
void ( * intf_PlaylistNext ) ( struct playlist_s * );
void ( * intf_PlaylistPrev ) ( struct playlist_s * );
void ( * intf_PlaylistDestroy ) ( struct playlist_s * );
void ( * intf_PlaylistJumpto ) ( struct playlist_s *, int );
void ( * intf_UrlDecode ) ( char * );
void ( * msleep ) ( mtime_t );
mtime_t ( * mdate ) ( void );
int ( * network_ChannelCreate )( void );
int ( * network_ChannelJoin ) ( int );
void ( * input_SetStatus ) ( struct input_thread_s *, int );
void ( * input_Seek ) ( struct input_thread_s *, off_t );
void ( * input_DumpStream ) ( struct input_thread_s * );
char * ( * input_OffsetToTime ) ( struct input_thread_s *, char *, off_t );
int ( * input_ChangeES ) ( struct input_thread_s *,
struct es_descriptor_s *, u8 );
int ( * input_ToggleES ) ( struct input_thread_s *,
struct es_descriptor_s *, boolean_t );
int ( * input_ChangeArea ) ( struct input_thread_s *,
struct input_area_s * );
struct es_descriptor_s * ( * input_FindES ) ( struct input_thread_s *,
u16 );
struct es_descriptor_s * ( * input_AddES ) ( struct input_thread_s *,
struct pgrm_descriptor_s *, u16, size_t );
void ( * input_DelES ) ( struct input_thread_s *,
struct es_descriptor_s * );
int ( * input_SelectES ) ( struct input_thread_s *,
struct es_descriptor_s * );
int ( * input_UnselectES ) ( struct input_thread_s *,
struct es_descriptor_s * );
struct pgrm_descriptor_s* ( * input_AddProgram ) ( struct input_thread_s *,
u16, size_t );
void ( * input_DelProgram ) ( struct input_thread_s *,
struct pgrm_descriptor_s * );
struct input_area_s * ( * input_AddArea ) ( struct input_thread_s * );
void ( * input_DelArea ) ( struct input_thread_s *,
struct input_area_s * );
void ( * InitBitstream ) ( struct bit_stream_s *,
struct decoder_fifo_s *,
void ( * ) ( struct bit_stream_s *,
boolean_t ),
void * );
int ( * input_InitStream ) ( struct input_thread_s *, size_t );
void ( * input_EndStream ) ( struct input_thread_s * );
void ( * input_ParsePES ) ( struct input_thread_s *,
struct es_descriptor_s * );
void ( * input_GatherPES ) ( struct input_thread_s *,
struct data_packet_s *,
struct es_descriptor_s *,
boolean_t, boolean_t );
void ( * input_DecodePES ) ( struct decoder_fifo_s *,
struct pes_packet_s * );
struct es_descriptor_s * ( * input_ParsePS ) ( struct input_thread_s *,
struct data_packet_s * );
void ( * input_DemuxPS ) ( struct input_thread_s *,
struct data_packet_s * );
void ( * input_DemuxTS ) ( struct input_thread_s *,
struct data_packet_s * );
void ( * input_DemuxPSI ) ( struct input_thread_s *,
struct data_packet_s *,
struct es_descriptor_s *,
boolean_t, boolean_t );
int ( * input_ClockManageControl ) ( struct input_thread_s *,
struct pgrm_descriptor_s *,
mtime_t );
int ( * input_NetlistInit ) ( struct input_thread_s *,
int, int, int, size_t, int );
struct iovec * ( * input_NetlistGetiovec ) ( void * p_method_data );
void ( * input_NetlistMviovec ) ( void * , int,
struct data_packet_s **);
struct data_packet_s * ( * input_NetlistNewPacket ) ( void *, size_t );
struct data_packet_s * ( * input_NetlistNewPtr ) ( void * );
struct pes_packet_s * ( * input_NetlistNewPES ) ( void * );
void ( * input_NetlistDeletePacket ) ( void *, struct data_packet_s * );
void ( * input_NetlistDeletePES ) ( void *, struct pes_packet_s * );
void ( * input_NetlistEnd ) ( struct input_thread_s * );
struct aout_fifo_s * ( * aout_CreateFifo )
( int, int, long, long, long, void * );
void ( * aout_DestroyFifo ) ( struct aout_fifo_s * );
struct vout_thread_s * (* vout_CreateThread) ( int *, int, int );
struct subpicture_s * (* vout_CreateSubPicture) ( struct vout_thread_s *,
int, int );
struct picture_s * ( * vout_CreatePicture ) ( struct vout_thread_s *,
int, int, int );
void ( * vout_DestroySubPicture ) ( struct vout_thread_s *,
struct subpicture_s * );
void ( * vout_DisplaySubPicture ) ( struct vout_thread_s *,
struct subpicture_s * );
void ( * vout_DisplayPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_DestroyPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_LinkPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_UnlinkPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_DatePicture ) ( struct vout_thread_s *p_vout,
struct picture_s *p_pic, mtime_t );
u32 ( * UnalignedShowBits ) ( struct bit_stream_s *, unsigned int );
void ( * UnalignedRemoveBits ) ( struct bit_stream_s * );
u32 ( * UnalignedGetBits ) ( struct bit_stream_s *, unsigned int );
char * ( * DecodeLanguage ) ( u16 );
struct module_s * ( * module_Need ) ( int, void * );
void ( * module_Unneed ) ( struct module_s * );
} module_symbols_t;
#ifdef PLUGIN
extern module_symbols_t* p_symbols;
#endif
......@@ -86,6 +86,10 @@
* status */
#define THREAD_SLEEP ((int)(0.010*CLOCK_FREQ))
/* When a thread waits on a condition in debug mode, delay to wait before
* outputting an error message (in second) */
#define THREAD_COND_TIMEOUT 5
/*
* Decoders FIFO configuration
*/
......
......@@ -20,154 +20,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
typedef struct module_symbols_s
{
struct main_s* p_main;
struct aout_bank_s* p_aout_bank;
struct vout_bank_s* p_vout_bank;
int ( * main_GetIntVariable ) ( char *, int );
char * ( * main_GetPszVariable ) ( char *, char * );
void ( * main_PutIntVariable ) ( char *, int );
void ( * main_PutPszVariable ) ( char *, char * );
int ( * TestProgram ) ( char * );
int ( * TestMethod ) ( char *, char * );
int ( * TestCPU ) ( int );
int ( * intf_ProcessKey ) ( struct intf_thread_s *, int );
void ( * intf_AssignKey ) ( struct intf_thread_s *, int, int, int );
void ( * intf_Msg ) ( char *, ... );
void ( * intf_ErrMsg ) ( char *, ... );
void ( * intf_StatMsg ) ( char *, ... );
void ( * intf_WarnMsg ) ( int, char *, ... );
void ( * intf_WarnMsgImm ) ( int, char *, ... );
#ifdef TRACE
void ( * intf_DbgMsg ) ( char *, char *, int, char *, ... );
void ( * intf_DbgMsgImm ) ( char *, char *, int, char *, ... );
#endif
int ( * intf_PlaylistAdd ) ( struct playlist_s *, int, const char* );
int ( * intf_PlaylistDelete ) ( struct playlist_s *, int );
void ( * intf_PlaylistNext ) ( struct playlist_s * );
void ( * intf_PlaylistPrev ) ( struct playlist_s * );
void ( * intf_PlaylistDestroy ) ( struct playlist_s * );
void ( * intf_PlaylistJumpto ) ( struct playlist_s *, int );
void ( * intf_UrlDecode ) ( char * );
void ( * msleep ) ( mtime_t );
mtime_t ( * mdate ) ( void );
int ( * network_ChannelCreate )( void );
int ( * network_ChannelJoin ) ( int );
void ( * input_SetStatus ) ( struct input_thread_s *, int );
void ( * input_Seek ) ( struct input_thread_s *, off_t );
void ( * input_DumpStream ) ( struct input_thread_s * );
char * ( * input_OffsetToTime ) ( struct input_thread_s *, char *, off_t );
int ( * input_ChangeES ) ( struct input_thread_s *,
struct es_descriptor_s *, u8 );
int ( * input_ToggleES ) ( struct input_thread_s *,
struct es_descriptor_s *, boolean_t );
int ( * input_ChangeArea ) ( struct input_thread_s *,
struct input_area_s * );
struct es_descriptor_s * ( * input_FindES ) ( struct input_thread_s *,
u16 );
struct es_descriptor_s * ( * input_AddES ) ( struct input_thread_s *,
struct pgrm_descriptor_s *, u16, size_t );
void ( * input_DelES ) ( struct input_thread_s *,
struct es_descriptor_s * );
int ( * input_SelectES ) ( struct input_thread_s *,
struct es_descriptor_s * );
int ( * input_UnselectES ) ( struct input_thread_s *,
struct es_descriptor_s * );
struct pgrm_descriptor_s* ( * input_AddProgram ) ( struct input_thread_s *,
u16, size_t );
void ( * input_DelProgram ) ( struct input_thread_s *,
struct pgrm_descriptor_s * );
struct input_area_s * ( * input_AddArea ) ( struct input_thread_s * );
void ( * input_DelArea ) ( struct input_thread_s *,
struct input_area_s * );
void ( * InitBitstream ) ( struct bit_stream_s *,
struct decoder_fifo_s *,
void ( * ) ( struct bit_stream_s *,
boolean_t ),
void * );
int ( * input_InitStream ) ( struct input_thread_s *, size_t );
void ( * input_EndStream ) ( struct input_thread_s * );
void ( * input_ParsePES ) ( struct input_thread_s *,
struct es_descriptor_s * );
void ( * input_GatherPES ) ( struct input_thread_s *,
struct data_packet_s *,
struct es_descriptor_s *,
boolean_t, boolean_t );
void ( * input_DecodePES ) ( struct decoder_fifo_s *,
struct pes_packet_s * );
struct es_descriptor_s * ( * input_ParsePS ) ( struct input_thread_s *,
struct data_packet_s * );
void ( * input_DemuxPS ) ( struct input_thread_s *,
struct data_packet_s * );
void ( * input_DemuxTS ) ( struct input_thread_s *,
struct data_packet_s * );
void ( * input_DemuxPSI ) ( struct input_thread_s *,
struct data_packet_s *,
struct es_descriptor_s *,
boolean_t, boolean_t );
int ( * input_ClockManageControl ) ( struct input_thread_s *,
struct pgrm_descriptor_s *,
mtime_t );
int ( * input_NetlistInit ) ( struct input_thread_s *,
int, int, int, size_t, int );
struct iovec * ( * input_NetlistGetiovec ) ( void * p_method_data );
void ( * input_NetlistMviovec ) ( void * , int,
struct data_packet_s **);
struct data_packet_s * ( * input_NetlistNewPacket ) ( void *, size_t );
struct data_packet_s * ( * input_NetlistNewPtr ) ( void * );
struct pes_packet_s * ( * input_NetlistNewPES ) ( void * );
void ( * input_NetlistDeletePacket ) ( void *, struct data_packet_s * );
void ( * input_NetlistDeletePES ) ( void *, struct pes_packet_s * );
void ( * input_NetlistEnd ) ( struct input_thread_s * );
struct aout_fifo_s * ( * aout_CreateFifo )
( int, int, long, long, long, void * );
void ( * aout_DestroyFifo ) ( struct aout_fifo_s * );
struct vout_thread_s * (* vout_CreateThread) ( int *, int, int );
struct subpicture_s * (* vout_CreateSubPicture) ( struct vout_thread_s *,
int, int );
struct picture_s * ( * vout_CreatePicture ) ( struct vout_thread_s *,
int, int, int );
void ( * vout_DestroySubPicture ) ( struct vout_thread_s *,
struct subpicture_s * );
void ( * vout_DisplaySubPicture ) ( struct vout_thread_s *,
struct subpicture_s * );
void ( * vout_DisplayPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_DestroyPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_LinkPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_UnlinkPicture ) ( struct vout_thread_s *,
struct picture_s * );
void ( * vout_DatePicture ) ( struct vout_thread_s *p_vout,
struct picture_s *p_pic, mtime_t );
u32 ( * UnalignedShowBits ) ( struct bit_stream_s *, unsigned int );
void ( * UnalignedRemoveBits ) ( struct bit_stream_s * );
u32 ( * UnalignedGetBits ) ( struct bit_stream_s *, unsigned int );
char * ( * DecodeLanguage ) ( u16 );
struct module_s * ( * module_Need ) ( int, void * );
void ( * module_Unneed ) ( struct module_s * );
} module_symbols_t;
#define STORE_SYMBOLS( p_symbols ) \
(p_symbols)->p_main = p_main; \
(p_symbols)->p_aout_bank = p_aout_bank; \
......@@ -257,8 +109,6 @@ typedef struct module_symbols_s
(p_symbols)->intf_DbgMsgImm = _intf_DbgMsgImm;
#ifdef PLUGIN
extern module_symbols_t* p_symbols;
# define p_main (p_symbols->p_main)
# define p_aout_bank (p_symbols->p_aout_bank)
# define p_vout_bank (p_symbols->p_vout_bank)
......
......@@ -9,7 +9,7 @@
* Functions prototyped are implemented in interface/mtime.c.
*****************************************************************************
* Copyright (C) 1996, 1997, 1998, 1999, 2000 VideoLAN
* $Id: mtime.h,v 1.7 2001/03/21 13:42:33 sam Exp $
* $Id: mtime.h,v 1.8 2001/11/28 15:08:04 massiot Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -34,18 +34,6 @@
* this header includes inline functions
*****************************************************************************/
/*****************************************************************************
* mtime_t: high precision date or time interval
*****************************************************************************
* Store an high precision date or time interval. The maximum precision is the
* micro-second, and a 64 bits integer is used to avoid any overflow (maximum
* time interval is then 292271 years, which should be length enough for any
* video). Date are stored as a time interval since a common date.
* Note that date and time intervals can be manipulated using regular arithmetic
* operators, and that no special functions are required.
*****************************************************************************/
typedef s64 mtime_t;
/*****************************************************************************
* LAST_MDATE: date which will never happen
*****************************************************************************
......
......@@ -3,7 +3,7 @@
* This header provides a portable threads implementation.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: threads.h,v 1.27 2001/11/25 22:52:21 gbazin Exp $
* $Id: threads.h,v 1.28 2001/11/28 15:08:04 massiot Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -25,7 +25,7 @@
#include <stdio.h>
#ifdef GPROF
#if defined(GPROF) || defined(DEBUG)
# include <sys/time.h>
#endif
......@@ -156,27 +156,11 @@ typedef void *(*vlc_thread_func_t)(void *p_data);
* Prototypes
*****************************************************************************/
static __inline__ int vlc_threads_init ( void );
static __inline__ int vlc_threads_end ( void );
static __inline__ int vlc_mutex_init ( vlc_mutex_t * );
static __inline__ int vlc_mutex_lock ( vlc_mutex_t * );
static __inline__ int vlc_mutex_unlock ( vlc_mutex_t * );
static __inline__ int vlc_mutex_destroy ( vlc_mutex_t * );
static __inline__ int vlc_cond_init ( vlc_cond_t * );
static __inline__ int vlc_cond_signal ( vlc_cond_t * );
static __inline__ int vlc_cond_wait ( vlc_cond_t *, vlc_mutex_t * );
static __inline__ int vlc_cond_destroy ( vlc_cond_t * );
static __inline__ int vlc_thread_create ( vlc_thread_t *, char *,
vlc_thread_func_t, void * );
static __inline__ void vlc_thread_exit ( void );
static __inline__ void vlc_thread_join ( vlc_thread_t );
#if 0
static __inline__ int vlc_cond_timedwait( vlc_cond_t *, vlc_mutex_t *,
mtime_t );
/* Message functions - this is kludgy because we are included before
* modules_export.h */
#ifdef PLUGIN
# define intf_ErrMsg p_symbols->intf_ErrMsg
# define intf_WarnMsg p_symbols->intf_WarnMsg
#endif
#ifdef GPROF
......@@ -320,13 +304,28 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex )
/*****************************************************************************
* vlc_mutex_lock: lock a mutex
*****************************************************************************/
static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex )
#ifdef DEBUG
# define vlc_mutex_lock( P_MUTEX ) \
_vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX )
#else
# define vlc_mutex_lock( P_MUTEX ) \
_vlc_mutex_lock( NULL, 0, P_MUTEX )
#endif
static __inline__ int _vlc_mutex_lock( char * psz_file, int i_line,
vlc_mutex_t *p_mutex )
{
#if defined( PTH_INIT_IN_PTH_H )
return pth_mutex_acquire( p_mutex, TRUE, NULL );
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
return pthread_mutex_lock( p_mutex );
int i_return = pthread_mutex_lock( p_mutex );
if( i_return )
{
intf_ErrMsg( "thread %d error: mutex_lock failed at %s:%d (%s)",
pthread_self(), psz_file, i_line, strerror(i_return) );
}
return i_return;
#elif defined( HAVE_CTHREADS_H )
mutex_lock( p_mutex );
......@@ -358,13 +357,28 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex )
/*****************************************************************************
* vlc_mutex_unlock: unlock a mutex
*****************************************************************************/
static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
#ifdef DEBUG
# define vlc_mutex_unlock( P_MUTEX ) \
_vlc_mutex_unlock( __FILE__, __LINE__, P_MUTEX )
#else
# define vlc_mutex_unlock( P_MUTEX ) \
_vlc_mutex_unlock( NULL, 0, P_MUTEX )
#endif
static __inline__ int _vlc_mutex_unlock( char * psz_file, int i_line,
vlc_mutex_t *p_mutex )
{
#if defined( PTH_INIT_IN_PTH_H )
return pth_mutex_release( p_mutex );
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
return pthread_mutex_unlock( p_mutex );
int i_return = pthread_mutex_unlock( p_mutex );
if( i_return )
{
intf_ErrMsg( "thread %d error: mutex_unlock failed at %s:%d (%s)",
pthread_self(), psz_file, i_line, strerror(i_return) );
}
return i_return;
#elif defined( HAVE_CTHREADS_H )
mutex_unlock( p_mutex );
......@@ -394,13 +408,28 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex )
/*****************************************************************************
* vlc_mutex_destroy: destroy a mutex
*****************************************************************************/
static __inline__ int vlc_mutex_destroy( vlc_mutex_t *p_mutex )
#ifdef DEBUG
# define vlc_mutex_destroy( P_MUTEX ) \
_vlc_mutex_destroy( __FILE__, __LINE__, P_MUTEX )
#else
# define vlc_mutex_destroy( P_MUTEX ) \
_vlc_mutex_destroy( NULL, 0, P_MUTEX )
#endif
static __inline__ int _vlc_mutex_destroy( char * psz_file, int i_line,
vlc_mutex_t *p_mutex )
{
#if defined( PTH_INIT_IN_PTH_H )
return 0;
#elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
return pthread_mutex_destroy( p_mutex );
int i_return = pthread_mutex_destroy( p_mutex );
if( i_return )
{
intf_ErrMsg( "thread %d error: mutex_destroy failed at %s:%d (%s)",