From ac08ae30411f18fccf735b337927ee7abd04a009 Mon Sep 17 00:00:00 2001 From: Jean-Marc Dressler Date: Sat, 4 Mar 2000 22:33:01 +0000 Subject: [PATCH] =?utf8?q?D=EF=BF=BDbut=20du=20portage=20BeOS.=20Beaucoup?= =?utf8?q?=20de=20fuchiers=20ont=20=EF=BF=BDt=EF=BF=BD=20modifi=EF=BF=BD?= =?utf8?q?=20car=20il=20a=20fallu=20r=EF=BF=BDorganiser=20les=20headers=20?= =?utf8?q?pour=20que=20ce=20soient=20les=20headers=20les=20plus=20proches?= =?utf8?q?=20du=20syst=EF=BF=BDme=20qui=20se=20retrouvent=20en=20premier?= =?utf8?q?=20(threads.h=20devrait=20toujours=20=EF=BF=BDtre=20le=20premier?= =?utf8?q?=20des=20headers=20non=20syst=EF=BF=BDmes).=20J'ai=20du=20aussi?= =?utf8?q?=20rajouter=20un=20type=20plugin=5Fid=5Ft=20et=20par=20la=20m?= =?utf8?q?=EF=BF=BDme=20occasion=20inclure=20plugins.h=20dans=20la=20plupa?= =?utf8?q?rt=20des=20fichiers.=20Voici=20en=20vrac=20les=20modifs=20les=20?= =?utf8?q?plus=20importantes=20que=20j'ai=20op=EF=BF=BDr=EF=BF=BD:?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit o L�g�re r�organisation pour les raisons �voqu�es ci-dessus (certaines macros comme MIN et MAX peuvent �tre d�j� d�finies par le syst�me et interf�rer avec celles d�finies dans common.h ou autre) o Dans intf_msg j'ai du remplacer les vasprintf par des vsprintf dans le cas o� ARCH=BEOS. o la commande hostname du Makefile n'�tait pas compatible et je l'ai donc enlev�, en avons-nous besoin ? Auquel cas il suffit de rajouter un ifeq. o J'ai aussi remplac� les bzero et bcopy par memset et memmove. o plugin.c, mtime.c et threads.h et quelques fichiers de l'input ont �t� adapt�s � BeOS � grand coup de #ifdef SYS_*. TODO: o Ecrire intf_beos.cpp, vout_beos.cpp et aout_beos.cpp Je suis sous linux et je viens de tester le client qui marche tr�s bien, mais il est n�anmoins possible que j'ai introduit quelques probl�mes de compilations pour certains modules, si c'est le cas pr�venez moi. --- Makefile | 12 +- include/audio_output.h | 2 +- include/common.h | 4 + include/config.h | 4 + include/interface.h | 2 +- include/plugins.h | 12 +- include/threads.h | 222 ++++++++++++++++++++++++-- include/video_output.h | 2 +- src/ac3_decoder/ac3_decoder_thread.c | 3 +- src/audio_decoder/audio_decoder.c | 3 +- src/audio_decoder/audio_math.c | 3 +- src/audio_output/audio_output.c | 35 ++-- src/input/input.c | 3 +- src/input/input_ctrl.c | 3 +- src/input/input_file.c | 2 +- src/input/input_netlist.c | 2 +- src/input/input_network.c | 6 +- src/input/input_pcr.c | 2 +- src/input/input_psi.c | 12 +- src/input/input_vlan.c | 15 +- src/interface/interface.c | 17 +- src/interface/intf_cmd.c | 3 +- src/interface/intf_ctrl.c | 3 +- src/interface/intf_msg.c | 13 +- src/interface/main.c | 12 +- src/misc/decoder_fifo.c | 2 +- src/misc/mtime.c | 27 ++++ src/misc/netutils.c | 13 +- src/misc/plugins.c | 50 ++++-- src/spu_decoder/spu_decoder.c | 2 +- src/video_decoder/vdec_idct.c | 3 +- src/video_decoder/vdec_motion.c | 3 +- src/video_decoder/vdec_motion_inner.c | 3 +- src/video_decoder/video_decoder.c | 3 +- src/video_output/video_output.c | 27 ++-- src/video_output/video_yuv.c | 3 +- src/video_parser/video_fifo.c | 3 +- src/video_parser/video_parser.c | 3 +- src/video_parser/vpar_blocks.c | 3 +- src/video_parser/vpar_headers.c | 3 +- src/video_parser/vpar_synchro.c | 3 +- 41 files changed, 437 insertions(+), 111 deletions(-) diff --git a/Makefile b/Makefile index e20f485182..8ab557efbc 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ ################################################################################ # Environment -CC=egcc +CC=gcc #CC=gcc295 SHELL=/bin/sh INSTALL=install @@ -30,7 +30,7 @@ VIDEO = x11 #VIDEO += ggi #VIDEO += glide # Not yet supported -#VIDEO += beos +#VIDEO = beos #VIDEO += dga # Fallback method that should always work VIDEO += dummy @@ -82,7 +82,9 @@ endif # PROGRAM_BUILD is a complete identification of the build # ( we can't use fancy options with date since OSes like Solaris # or FreeBSD have strange date implementations ) -PROGRAM_BUILD = `date` $(USER)@`hostname` +PROGRAM_BUILD = `date` $(USER) +# XXX: beos does not support hostname +#PROGRAM_BUILD = `date` $(USER)@`hostname` # DEFINE will contain some of the constants definitions decided in Makefile, # including ARCH_xx and SYS_xx. It will be passed to C compiler. @@ -124,6 +126,10 @@ ifeq ($(SYS),LINUX) LIB += -lpthread -ldl endif +ifeq ($SYS),BEOS) +LIB += -llibroot -llibgame -llibbe +endif + LIB += -lm # diff --git a/include/audio_output.h b/include/audio_output.h index 17e9c34f20..3bc7fbaccd 100644 --- a/include/audio_output.h +++ b/include/audio_output.h @@ -184,7 +184,7 @@ typedef struct aout_thread_s aout_fifo_t fifo[ AOUT_MAX_FIFOS ]; /* Plugins */ - void * p_aout_plugin; /* video output plugin */ + plugin_id_t aout_plugin; /* video output plugin */ aout_sys_open_t * p_sys_open; aout_sys_reset_t * p_sys_reset; aout_sys_setformat_t * p_sys_setformat; diff --git a/include/common.h b/include/common.h index cc49cd5352..e9e105df42 100644 --- a/include/common.h +++ b/include/common.h @@ -103,8 +103,12 @@ typedef struct video_parser_s * p_video_parser_t; #define PAD(n, d) ( ((n) % (d)) ? ((((n) / (d)) + 1) * (d)) : (n) ) /* MAX and MIN: self explanatory */ +#ifndef MAX #define MAX(a, b) ( ((a) > (b)) ? (a) : (b) ) +#endif +#ifndef MIN #define MIN(a, b) ( ((a) < (b)) ? (a) : (b) ) +#endif /* MSB (big endian)/LSB (little endian) convertions - network order is always * MSB, and should be used for both network communications and files. Note that diff --git a/include/config.h b/include/config.h index 6a79293e3a..0f0dd3b683 100644 --- a/include/config.h +++ b/include/config.h @@ -373,6 +373,10 @@ * Messages and console interfaces configuration *****************************************************************************/ +/* Maximal size of a message to be stored in the mesage queue, + * it is needed when vasprintf is not avalaible */ +#define INTF_MAX_MSG_SIZE 512 + /* Maximal size of the message queue - in case of overflow, all messages in the * queue are printed by the calling thread */ #define INTF_MSG_QSIZE 64 diff --git a/include/interface.h b/include/interface.h index 2a8f55c3c7..d9c7b7ae46 100644 --- a/include/interface.h +++ b/include/interface.h @@ -58,7 +58,7 @@ typedef struct intf_thread_s p_intf_sys_t p_sys; /* system interface */ /* Plugin */ - void * p_intf_plugin; /* interface plugin */ + plugin_id_t intf_plugin; /* interface plugin */ intf_sys_create_t * p_sys_create; /* create interface thread */ intf_sys_manage_t * p_sys_manage; /* main loop */ intf_sys_destroy_t * p_sys_destroy; /* destroy interface */ diff --git a/include/plugins.h b/include/plugins.h index e5d042a97c..7c2629d0ff 100644 --- a/include/plugins.h +++ b/include/plugins.h @@ -21,7 +21,13 @@ * Boston, MA 02111-1307, USA. *****************************************************************************/ -void * RequestPlugin ( char * psz_mask, char * psz_name ); -void TrashPlugin ( void * p_plugin ); -void * GetPluginFunction ( void *plugin, char *name ); +#ifdef SYS_BEOS +typedef int plugin_id_t; +#else +typedef void* plugin_id_t; +#endif + +int RequestPlugin ( plugin_id_t * p_plugin, char * psz_mask, char * psz_name ); +void TrashPlugin ( plugin_id_t p_plugin ); +void * GetPluginFunction ( plugin_id_t plugin, char *name ); diff --git a/include/threads.h b/include/threads.h index 73fb41d67a..56c5e7d5e7 100644 --- a/include/threads.h +++ b/include/threads.h @@ -24,9 +24,17 @@ * Boston, MA 02111-1307, USA. *****************************************************************************/ + #ifdef SYS_GNU #include -#else +#endif + +#ifdef SYS_BEOS +#include +#include +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) #include #endif @@ -80,13 +88,38 @@ typedef struct s_condition { struct cond_imp *implications; } vlc_cond_t; -#else /* SYS_GNU */ +#endif /* SYS_GNU */ + +#ifdef SYS_BEOS + +typedef thread_id vlc_thread_t; + +typedef struct +{ + int32 init; + sem_id lock; + thread_id owner; +} vlc_mutex_t; + +typedef struct +{ + int32 init; + sem_id sem; + sem_id handshakeSem; + sem_id signalSem; + volatile int32 nw; + volatile int32 ns; +} vlc_cond_t; + +#endif /* SYS_BEOS */ + +#if defined(SYS_LINUX) || defined(SYS_BSD) typedef pthread_t vlc_thread_t; typedef pthread_mutex_t vlc_mutex_t; typedef pthread_cond_t vlc_cond_t; -#endif /* SYS_GNU */ +#endif /* SYS_LINUX || SYS_BSD */ typedef void *(*vlc_thread_func_t)(void *p_data); @@ -122,7 +155,14 @@ static __inline__ int vlc_thread_create( vlc_thread_t *p_thread, #ifdef SYS_GNU *p_thread = cthread_fork( (cthread_fn_t)func, (any_t)p_data ); return( 0 ); -#else +#endif + +#ifdef SYS_BEOS + *p_thread = spawn_thread( (thread_func)func, psz_name, B_NORMAL_PRIORITY, p_data ); + return resume_thread( *p_thread ); +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) return pthread_create( p_thread, NULL, func, p_data ); #endif } @@ -135,7 +175,13 @@ static __inline__ void vlc_thread_exit( void ) #ifdef SYS_GNU int result; cthread_exit( &result ); -#else +#endif + +#ifdef SYS_BEOS + exit_thread( 0 ); +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) pthread_exit( 0 ); #endif } @@ -147,11 +193,34 @@ static __inline__ void vlc_thread_join( vlc_thread_t thread ) { #ifdef SYS_GNU cthread_join( thread ); -#else +#endif + +#ifdef SYS_BEOS + int32 exit_value; + wait_for_thread( thread, &exit_value ); +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) pthread_join( thread, NULL ); #endif } +#ifdef SYS_BEOS +/* lazy_init_mutex */ +static __inline__ void lazy_init_mutex(vlc_mutex_t* p_mutex) +{ + int32 v = atomic_or( &p_mutex->init, 1 ); + if( 2000 == v ) // we're the first, so do the init + { + vlc_mutex_init( p_mutex ); + } + else // we're not the first, so wait until the init is finished + { + while( p_mutex->init != 9999 ) snooze( 10000 ); + } +} +#endif + /***************************************************************************** * vlc_mutex_init: initialize a mutex *****************************************************************************/ @@ -160,7 +229,20 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex ) #ifdef SYS_GNU mutex_init( p_mutex ); return( 0 ); -#else +#endif + +#ifdef SYS_BEOS + // check the arguments and whether it's already been initialized + if( !p_mutex ) return B_BAD_VALUE; + if( p_mutex->init == 9999 ) return EALREADY; + + p_mutex->lock = create_sem( 1, "BeMutex" ); + p_mutex->owner = -1; + p_mutex->init = 9999; + return B_OK; +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) return pthread_mutex_init( p_mutex, NULL ); #endif } @@ -173,7 +255,21 @@ static __inline__ int vlc_mutex_lock( vlc_mutex_t *p_mutex ) #ifdef SYS_GNU mutex_lock( p_mutex ); return( 0 ); -#else +#endif + +#ifdef SYS_BEOS + status_t err; + + if( !p_mutex ) return B_BAD_VALUE; + if( p_mutex->init < 2000 ) return B_NO_INIT; + lazy_init_mutex( p_mutex ); + + err = acquire_sem( p_mutex->lock ); + if( !err ) p_mutex->owner = find_thread( NULL ); + return err; +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) return pthread_mutex_lock( p_mutex ); #endif } @@ -186,11 +282,40 @@ static __inline__ int vlc_mutex_unlock( vlc_mutex_t *p_mutex ) #ifdef SYS_GNU mutex_unlock( p_mutex ); return( 0 ); -#else +#endif + +#ifdef SYS_BEOS + if(! p_mutex) return B_BAD_VALUE; + if( p_mutex->init < 2000 ) return B_NO_INIT; + lazy_init_mutex( p_mutex ); + + if( p_mutex->owner != find_thread(NULL) ) return ENOLCK; + p_mutex->owner = -1; + release_sem( p_mutex->lock ); + return B_OK; +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) return pthread_mutex_unlock( p_mutex ); #endif } +#ifdef SYS_BEOS +/* lazy_init_cond */ +static __inline__ void lazy_init_cond( vlc_cond_t* p_condvar ) +{ + int32 v = atomic_or( &p_condvar->init, 1 ); + if( 2000 == v ) // we're the first, so do the init + { + vlc_cond_init( p_condvar ); + } + else // we're not the first, so wait until the init is finished + { + while( p_condvar->init != 9999 ) snooze( 10000 ); + } +} +#endif + /***************************************************************************** * vlc_cond_init: initialize a condition *****************************************************************************/ @@ -204,7 +329,21 @@ static __inline__ int vlc_cond_init( vlc_cond_t *p_condvar ) p_condvar->implications = 0; return( 0 ); -#else +#endif + +#ifdef SYS_BEOS + if( !p_condvar ) return B_BAD_VALUE; + if( p_condvar->init == 9999 ) return EALREADY; + + p_condvar->sem = create_sem( 0, "CVSem" ); + p_condvar->handshakeSem = create_sem( 0, "CVHandshake" ); + p_condvar->signalSem = create_sem( 1, "CVSignal" ); + p_condvar->ns = p_condvar->nw = 0; + p_condvar->init = 9999; + return B_OK; +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) return pthread_cond_init( p_condvar, NULL ); #endif } @@ -221,7 +360,33 @@ static __inline__ int vlc_cond_signal( vlc_cond_t *p_condvar ) cond_signal( (condition_t)p_condvar ); } return( 0 ); -#else +#endif + +#ifdef SYS_BEOS + status_t err = B_OK; + + if( !p_condvar ) return B_BAD_VALUE; + if( p_condvar->init < 2000 ) return B_NO_INIT; + lazy_init_cond( p_condvar ); + + if( acquire_sem(p_condvar->signalSem) == B_INTERRUPTED) return B_INTERRUPTED; + + if( p_condvar->nw > p_condvar->ns ) + { + p_condvar->ns += 1; + release_sem( p_condvar->sem ); + release_sem( p_condvar->signalSem ); + while( acquire_sem(p_condvar->handshakeSem) == B_INTERRUPTED ) + { err = B_INTERRUPTED; } + } + else + { + release_sem( p_condvar->signalSem ); + } + return err; +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) return pthread_cond_signal( p_condvar ); #endif } @@ -234,8 +399,39 @@ static __inline__ int vlc_cond_wait( vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex #ifdef SYS_GNU condition_wait( (condition_t)p_condvar, (mutex_t)p_mutex ); return( 0 ); -#else +#endif + +#ifdef SYS_BEOS + status_t err; + + if( !p_condvar ) return B_BAD_VALUE; + if( !p_mutex ) return B_BAD_VALUE; + if( p_condvar->init < 2000 ) return B_NO_INIT; + lazy_init_cond( p_condvar ); + + if( acquire_sem(p_condvar->signalSem) == B_INTERRUPTED ) return B_INTERRUPTED; + p_condvar->nw += 1; + release_sem( p_condvar->signalSem ); + + vlc_mutex_unlock( p_mutex ); + err = acquire_sem( p_condvar->sem ); + + while( acquire_sem(p_condvar->signalSem) == B_INTERRUPTED) + { err = B_INTERRUPTED; } + if( p_condvar->ns > 0 ) + { + release_sem( p_condvar->handshakeSem ); + p_condvar->ns -= 1; + } + p_condvar->nw -= 1; + release_sem( p_condvar->signalSem ); + + while( vlc_mutex_lock(p_mutex) == B_INTERRUPTED) + { err = B_INTERRUPTED; } + return err; +#endif + +#if defined(SYS_LINUX) || defined(SYS_BSD) return pthread_cond_wait( p_condvar, p_mutex ); #endif } - diff --git a/include/video_output.h b/include/video_output.h index e61ae7c6ef..ce917e0c71 100644 --- a/include/video_output.h +++ b/include/video_output.h @@ -152,7 +152,7 @@ typedef struct vout_thread_s u32 i_blue_pixel; /* blue */ /* Plugins */ - void * p_vout_plugin; /* video output plugin */ + plugin_id_t vout_plugin; /* video output plugin */ vout_sys_create_t * p_sys_create; /* allocate output method */ vout_sys_init_t * p_sys_init; /* initialize output method */ vout_sys_end_t * p_sys_end; /* terminate output method */ diff --git a/src/ac3_decoder/ac3_decoder_thread.c b/src/ac3_decoder/ac3_decoder_thread.c index 3038448f35..76b1def656 100644 --- a/src/ac3_decoder/ac3_decoder_thread.c +++ b/src/ac3_decoder/ac3_decoder_thread.c @@ -40,10 +40,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* "input.h" */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "debug.h" /* "input_netlist.h" */ #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */ diff --git a/src/audio_decoder/audio_decoder.c b/src/audio_decoder/audio_decoder.c index a3620bafe2..48567fbedd 100644 --- a/src/audio_decoder/audio_decoder.c +++ b/src/audio_decoder/audio_decoder.c @@ -39,10 +39,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* "input.h" */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "debug.h" /* "input_netlist.h" */ #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */ diff --git a/src/audio_decoder/audio_math.c b/src/audio_decoder/audio_math.c index 17832d7b1b..1200f0cb2a 100644 --- a/src/audio_decoder/audio_math.c +++ b/src/audio_decoder/audio_math.c @@ -29,10 +29,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* "input.h" */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" /* mtime_t */ -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */ diff --git a/src/audio_output/audio_output.c b/src/audio_output/audio_output.c index ca22fbc391..6b951162d3 100644 --- a/src/audio_output/audio_output.c +++ b/src/audio_output/audio_output.c @@ -41,10 +41,10 @@ #include /* "intf_msg.h" */ #include /* calloc(), malloc(), free() */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" /* mtime_t, mdate(), msleep() */ -#include "threads.h" #include "plugins.h" #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */ @@ -93,9 +93,8 @@ aout_thread_t *aout_CreateThread( int *pi_status ) /* Request an interface plugin */ psz_method = main_GetPszVariable( AOUT_METHOD_VAR, AOUT_DEFAULT_METHOD ); - p_aout->p_aout_plugin = RequestPlugin( "aout", psz_method ); - if( !p_aout->p_aout_plugin ) + if( RequestPlugin( &p_aout->aout_plugin, "aout", psz_method ) ) { intf_ErrMsg( "error: could not open audio plugin aout_%s.so\n", psz_method ); free( p_aout ); @@ -103,21 +102,21 @@ aout_thread_t *aout_CreateThread( int *pi_status ) } /* Get plugins */ - p_aout->p_sys_open = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysOpen" ); - p_aout->p_sys_reset = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysReset" ); - p_aout->p_sys_setformat = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysSetFormat" ); - p_aout->p_sys_setchannels = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysSetChannels" ); - p_aout->p_sys_setrate = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysSetRate" ); - p_aout->p_sys_getbufinfo = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysGetBufInfo" ); - p_aout->p_sys_playsamples = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysPlaySamples" ); - p_aout->p_sys_close = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysClose" ); + p_aout->p_sys_open = GetPluginFunction( p_aout->aout_plugin, "aout_SysOpen" ); + p_aout->p_sys_reset = GetPluginFunction( p_aout->aout_plugin, "aout_SysReset" ); + p_aout->p_sys_setformat = GetPluginFunction( p_aout->aout_plugin, "aout_SysSetFormat" ); + p_aout->p_sys_setchannels = GetPluginFunction( p_aout->aout_plugin, "aout_SysSetChannels" ); + p_aout->p_sys_setrate = GetPluginFunction( p_aout->aout_plugin, "aout_SysSetRate" ); + p_aout->p_sys_getbufinfo = GetPluginFunction( p_aout->aout_plugin, "aout_SysGetBufInfo" ); + p_aout->p_sys_playsamples = GetPluginFunction( p_aout->aout_plugin, "aout_SysPlaySamples" ); + p_aout->p_sys_close = GetPluginFunction( p_aout->aout_plugin, "aout_SysClose" ); /* * Initialize audio device */ if ( p_aout->p_sys_open( p_aout ) ) { - TrashPlugin( p_aout->p_aout_plugin ); + TrashPlugin( p_aout->aout_plugin ); free( p_aout ); return( NULL ); } @@ -128,28 +127,28 @@ aout_thread_t *aout_CreateThread( int *pi_status ) if ( p_aout->p_sys_reset( p_aout ) ) { p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->p_aout_plugin ); + TrashPlugin( p_aout->aout_plugin ); free( p_aout ); return( NULL ); } if ( p_aout->p_sys_setformat( p_aout ) ) { p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->p_aout_plugin ); + TrashPlugin( p_aout->aout_plugin ); free( p_aout ); return( NULL ); } if ( p_aout->p_sys_setchannels( p_aout ) ) { p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->p_aout_plugin ); + TrashPlugin( p_aout->aout_plugin ); free( p_aout ); return( NULL ); } if ( p_aout->p_sys_setrate( p_aout ) ) { p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->p_aout_plugin ); + TrashPlugin( p_aout->aout_plugin ); free( p_aout ); return( NULL ); } @@ -160,7 +159,7 @@ aout_thread_t *aout_CreateThread( int *pi_status ) if( aout_SpawnThread( p_aout ) ) { p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->p_aout_plugin ); + TrashPlugin( p_aout->aout_plugin ); free( p_aout ); return( NULL ); } @@ -327,7 +326,7 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status ) intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->psz_device); /* Close plugin */ - TrashPlugin( p_aout->p_aout_plugin ); + TrashPlugin( p_aout->aout_plugin ); /* Free structure */ free( p_aout ); diff --git a/src/input/input.c b/src/input/input.c index a7d9f74285..85adfe29f6 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -34,11 +34,12 @@ #include /* free() */ #include /* ntohs() */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" #include "intf_msg.h" +#include "plugins.h" #include "debug.h" #include "input.h" diff --git a/src/input/input_ctrl.c b/src/input/input_ctrl.c index 41c7b015a6..7e482d745c 100644 --- a/src/input/input_ctrl.c +++ b/src/input/input_ctrl.c @@ -31,11 +31,12 @@ #include /* ntohs */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" #include "intf_msg.h" +#include "plugins.h" #include "debug.h" #include "input.h" diff --git a/src/input/input_file.c b/src/input/input_file.c index 32949453ba..5754dd7f61 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -27,10 +27,10 @@ #include /* on BSD, uio.h needs types.h */ #include /* "input.h" */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" #include "input.h" #include "input_file.h" diff --git a/src/input/input_netlist.c b/src/input/input_netlist.c index e1b2b398dc..724e4a3cd0 100644 --- a/src/input/input_netlist.c +++ b/src/input/input_netlist.c @@ -32,10 +32,10 @@ #include /* strerror() */ #include /* errno */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" #include "intf_msg.h" #include "debug.h" #include "input.h" diff --git a/src/input/input_network.c b/src/input/input_network.c index 5781711815..f69244df81 100644 --- a/src/input/input_network.c +++ b/src/input/input_network.c @@ -32,17 +32,17 @@ #include /* errno */ #include /* "input_network.h" */ -#ifdef SYS_BSD +#if defined(SYS_BSD) || defined(SYS_BEOS) #include /* struct sockaddr */ #endif #include /* servent, getservbyname(), hostent, gethostbyname() */ #include /* sockaddr_in, htons(), htonl() */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" #include "netutils.h" #include "input.h" @@ -96,6 +96,7 @@ int input_NetworkOpen( input_thread_t *p_input ) return( 1 ); } +#ifndef SYS_BEOS /* Increase the receive buffer size to 1/2MB (8Mb/s during 1/2s) to avoid * packet loss caused by scheduling problems */ i_socket_option = 524288; @@ -109,6 +110,7 @@ int input_NetworkOpen( input_thread_t *p_input ) close( p_input->i_handle ); return( 1 ); } +#endif /* SYS_BEOS */ /* * Bind the socket diff --git a/src/input/input_pcr.c b/src/input/input_pcr.c index 11a5e51ae9..57af8a70b3 100644 --- a/src/input/input_pcr.c +++ b/src/input/input_pcr.c @@ -30,10 +30,10 @@ #include /* atoi(), malloc(), free() */ #include /* ntohl() */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" #include "debug.h" #include "input.h" #include "intf_msg.h" diff --git a/src/input/input_psi.c b/src/input/input_psi.c index b03745dab1..0154277532 100644 --- a/src/input/input_psi.c +++ b/src/input/input_psi.c @@ -32,10 +32,10 @@ #include /* bzero() */ #include /* ntohs() */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" #include "intf_msg.h" #include "debug.h" @@ -1109,19 +1109,19 @@ static stream_descriptor_t* AddStreamDescr(input_thread_t* p_input, p_input->p_stream->i_PAT_version = PSI_UNINITIALISED; p_input->p_stream->i_known_PAT_sections = 0; - bzero( p_input->p_stream->a_known_PAT_sections, - sizeof(*p_input->p_stream->a_known_PAT_sections) ); + memset( p_input->p_stream->a_known_PAT_sections, 0, + sizeof(*p_input->p_stream->a_known_PAT_sections) ); p_input->p_stream->b_is_PAT_complete = 0; p_input->p_stream->i_known_PMT_sections = 0; - bzero( p_input->p_stream->a_known_PMT_sections, - sizeof(*p_input->p_stream->a_known_PMT_sections) ); + memset( p_input->p_stream->a_known_PMT_sections, 0, + sizeof(*p_input->p_stream->a_known_PMT_sections) ); p_input->p_stream->b_is_PMT_complete = 0; #ifdef DVB_EXTENSIONS p_input->p_stream->i_SDT_version = PSI_UNINITIALISED; p_input->p_stream->i_known_SDT_sections = 0; - bzero( p_input->p_stream->a_known_SDT_sections, + memset( p_input->p_stream->a_known_SDT_sections, 0, sizeof(*p_input->p_stream->a_known_SDT_sections) ); p_input->p_stream->b_is_SDT_complete = 0; #endif diff --git a/src/input/input_vlan.c b/src/input/input_vlan.c index c901077d73..a089abe6bf 100644 --- a/src/input/input_vlan.c +++ b/src/input/input_vlan.c @@ -30,22 +30,24 @@ #include /* strerror(), bzero() */ #include /* free() */ -#ifdef SYS_BSD +#if defined(SYS_BSD) || defined(SYS_BEOS) #include /* struct in_addr */ #include /* struct sockaddr */ #endif +#if defined(SYS_LINUX) || defined(SYS_BSD) || defined(SYS_GNU) #include /* inet_ntoa(), inet_aton() */ +#endif #ifdef SYS_LINUX #include /* ioctl() */ #include /* interface (arch-dependent) */ #endif +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" #include "netutils.h" #include "input_vlan.h" #include "intf_msg.h" @@ -76,6 +78,10 @@ static int ZeTrucMucheFunction( int Channel ); *****************************************************************************/ int input_VlanCreate( void ) { +#ifdef SYS_BEOS + intf_ErrMsg( "error: vlans are not supported under beos\n" ); + return( 1 ); +#else /* Allocate structure */ p_main->p_vlan = malloc( sizeof( input_vlan_t ) ); if( p_main->p_vlan == NULL ) @@ -90,6 +96,7 @@ int input_VlanCreate( void ) intf_Msg("VLANs initialized\n"); return( 0 ); +#endif /* SYS_BEOS */ } /***************************************************************************** @@ -123,6 +130,9 @@ void input_VlanDestroy( void ) *****************************************************************************/ int input_VlanJoin( int i_vlan_id ) { +#ifdef SYS_BEOS + return( -1 ); +#else /* If last change is too recent, wait a while */ if( mdate() - p_main->p_vlan->last_change < INPUT_VLAN_CHANGE_DELAY ) { @@ -134,6 +144,7 @@ int input_VlanJoin( int i_vlan_id ) intf_Msg("Joining VLAN %d (channel %d)\n", i_vlan_id + 2, i_vlan_id ); return( ZeTrucMucheFunction( i_vlan_id ) ); /* FIXME: join vlan ?? */ +#endif /* SYS_BEOS */ } /***************************************************************************** diff --git a/src/interface/interface.c b/src/interface/interface.c index cd869c39ab..e8c49b944f 100644 --- a/src/interface/interface.c +++ b/src/interface/interface.c @@ -33,10 +33,10 @@ #include /* on BSD, uio.h needs types.h */ #include /* for input.h */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" #include "plugins.h" #include "input.h" @@ -99,9 +99,8 @@ intf_thread_t* intf_Create( void ) /* Request an interface plugin */ psz_method = main_GetPszVariable( VOUT_METHOD_VAR, VOUT_DEFAULT_METHOD ); - p_intf->p_intf_plugin = RequestPlugin( "intf", psz_method ); - if( !p_intf->p_intf_plugin ) + if( RequestPlugin( &p_intf->intf_plugin, "intf", psz_method ) < 0 ) { intf_ErrMsg( "error: could not open interface plugin intf_%s.so\n", psz_method ); free( p_intf ); @@ -109,9 +108,9 @@ intf_thread_t* intf_Create( void ) } /* Get plugins */ - p_intf->p_sys_create = GetPluginFunction( p_intf->p_intf_plugin, "intf_SysCreate" ); - p_intf->p_sys_manage = GetPluginFunction( p_intf->p_intf_plugin, "intf_SysManage" ); - p_intf->p_sys_destroy = GetPluginFunction( p_intf->p_intf_plugin, "intf_SysDestroy" ); + p_intf->p_sys_create = GetPluginFunction( p_intf->intf_plugin, "intf_SysCreate" ); + p_intf->p_sys_manage = GetPluginFunction( p_intf->intf_plugin, "intf_SysManage" ); + p_intf->p_sys_destroy = GetPluginFunction( p_intf->intf_plugin, "intf_SysDestroy" ); /* Initialize structure */ p_intf->b_die = 0; @@ -128,7 +127,7 @@ intf_thread_t* intf_Create( void ) if( p_intf->p_console == NULL ) { intf_ErrMsg("error: can't create control console\n"); - TrashPlugin( p_intf->p_intf_plugin ); + TrashPlugin( p_intf->intf_plugin ); free( p_intf ); return( NULL ); } @@ -136,7 +135,7 @@ intf_thread_t* intf_Create( void ) { intf_ErrMsg("error: can't create interface\n"); intf_ConsoleDestroy( p_intf->p_console ); - TrashPlugin( p_intf->p_intf_plugin ); + TrashPlugin( p_intf->intf_plugin ); free( p_intf ); return( NULL ); } @@ -202,7 +201,7 @@ void intf_Destroy( intf_thread_t *p_intf ) UnloadChannels( p_intf ); /* Close plugin */ - TrashPlugin( p_intf->p_intf_plugin ); + TrashPlugin( p_intf->intf_plugin ); /* Free structure */ free( p_intf ); diff --git a/src/interface/intf_cmd.c b/src/interface/intf_cmd.c index 6ccb75bcc2..91b8adb20c 100644 --- a/src/interface/intf_cmd.c +++ b/src/interface/intf_cmd.c @@ -32,10 +32,11 @@ #include /* strtod(), strtol() */ #include /* strerror() */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "interface.h" #include "intf_msg.h" diff --git a/src/interface/intf_ctrl.c b/src/interface/intf_ctrl.c index 5ccff0acbe..797f770f30 100644 --- a/src/interface/intf_ctrl.c +++ b/src/interface/intf_ctrl.c @@ -50,11 +50,12 @@ #include /* open() */ /* Common headers */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" #include "debug.h" +#include "plugins.h" #include "intf_msg.h" #include "input.h" diff --git a/src/interface/intf_msg.c b/src/interface/intf_msg.c index 7fb09521b1..5a8376b99e 100644 --- a/src/interface/intf_msg.c +++ b/src/interface/intf_msg.c @@ -34,10 +34,11 @@ #include /* strerror() */ #include /* close(), write() */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" #include "interface.h" #include "intf_console.h" @@ -345,7 +346,12 @@ static void QueueMsg( intf_msg_t *p_msg, int i_type, char *psz_format, va_list a /* * Convert message to string */ +#ifdef SYS_BEOS + psz_str = (char*) malloc( INTF_MAX_MSG_SIZE ); + vsprintf( psz_str, psz_format, ap ); +#else vasprintf( &psz_str, psz_format, ap ); +#endif if( psz_str == NULL ) { fprintf(stderr, "warning: can't store following message (%s): ", @@ -401,7 +407,12 @@ static void QueueDbgMsg(intf_msg_t *p_msg, char *psz_file, char *psz_function, /* * Convert message to string */ +#ifdef SYS_BEOS + psz_str = (char*) malloc( INTF_MAX_MSG_SIZE ); + vsprintf( psz_str, psz_format, ap ); +#else vasprintf( &psz_str, psz_format, ap ); +#endif if( psz_str == NULL ) { fprintf(stderr, "warning: can't store following message (%s): ", diff --git a/src/interface/main.c b/src/interface/main.c index 95dda7794d..4969b50e68 100644 --- a/src/interface/main.c +++ b/src/interface/main.c @@ -26,18 +26,19 @@ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* getopt() */ #include /* SIGHUP, SIGINT, SIGKILL */ +#include /* getopt() */ #include /* sprintf() */ #include /* ENOMEM */ #include /* getenv(), strtol(), */ #include /* strerror() */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "input_vlan.h" #include "intf_msg.h" @@ -574,6 +575,9 @@ static void SignalHandler( int i_signal ) *****************************************************************************/ static int TestMMX( void ) { +/* FIXME: under beos, gcc does not support the foolowing inline assembly */ +#ifndef SYS_BEOS + int i_reg, i_dummy = 0; /* test for a 386 cpu */ @@ -635,5 +639,9 @@ static int TestMMX( void ) return( 0 ); return( 1 ); + +#else /* SYS_BEOS */ + return( 1 ); +#endif /* SYS_BEOS */ } #endif diff --git a/src/misc/decoder_fifo.c b/src/misc/decoder_fifo.c index f0a4c9031f..1431ca5856 100644 --- a/src/misc/decoder_fifo.c +++ b/src/misc/decoder_fifo.c @@ -24,10 +24,10 @@ #include /* on BSD, uio.h needs types.h */ #include /* for input.h */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" #include "debug.h" /* XXX?? temporaire, requis par netlist.h */ diff --git a/src/misc/mtime.c b/src/misc/mtime.c index 2f2b42b359..cd11520ae0 100644 --- a/src/misc/mtime.c +++ b/src/misc/mtime.c @@ -34,6 +34,10 @@ #include /* select() */ #include +#ifdef SYS_BEOS +#include +#endif + #include "common.h" #include "mtime.h" @@ -63,6 +67,9 @@ char *mstrtime( char *psz_buffer, mtime_t date ) *****************************************************************************/ mtime_t mdate( void ) { +#ifdef SYS_BEOS + return( real_time_clock_usecs() ); +#else struct timeval tv_date; /* gettimeofday() could return an error, and should be tested. However, the @@ -70,6 +77,7 @@ mtime_t mdate( void ) * here, since tv is a local variable. */ gettimeofday( &tv_date, NULL ); return( (mtime_t) tv_date.tv_sec * 1000000 + (mtime_t) tv_date.tv_usec ); +#endif } /***************************************************************************** @@ -81,6 +89,17 @@ mtime_t mdate( void ) *****************************************************************************/ void mwait( mtime_t date ) { +#ifdef SYS_BEOS + mtime_t delay; + + delay = date - real_time_clock_usecs(); + if( delay <= 0 ) + { + return; + } + snooze( delay ); +#else /* SYS_BEOS */ + struct timeval tv_date, tv_delay; mtime_t delay; /* delay in msec, signed to detect errors */ @@ -102,6 +121,8 @@ void mwait( mtime_t date ) #else usleep( delay ); #endif + +#endif /* SYS_BEOS */ } /***************************************************************************** @@ -111,6 +132,10 @@ void mwait( mtime_t date ) *****************************************************************************/ void msleep( mtime_t delay ) { +#ifdef SYS_BEOS + snooze( delay ); +#else /* SYS_BEOS */ + #ifndef usleep struct timeval tv_delay; @@ -124,4 +149,6 @@ void msleep( mtime_t delay ) #else usleep( delay ); #endif + +#endif /* SYS_BEOS */ } diff --git a/src/misc/netutils.c b/src/misc/netutils.c index 2aeed67c73..6566f21c97 100644 --- a/src/misc/netutils.c +++ b/src/misc/netutils.c @@ -34,7 +34,10 @@ #include /* struct sockaddr */ #endif -#include /* htons(), htonl() */ +#if defined(SYS_LINUX) || defined(SYS_BSD) || defined(SYS_GNU) +#include /* inet_ntoa(), inet_aton() */ +#endif + #ifdef SYS_LINUX #include /* ioctl() */ @@ -62,7 +65,7 @@ int BuildInetAddr( struct sockaddr_in *p_sa_in, char *psz_in_addr, int i_port ) { struct hostent *p_hostent; /* host descriptor */ - bzero( p_sa_in, sizeof( struct sockaddr_in ) ); + memset( p_sa_in, 0, sizeof( struct sockaddr_in ) ); p_sa_in->sin_family = AF_INET; /* family */ p_sa_in->sin_port = htons( i_port ); /* port */ @@ -73,7 +76,11 @@ int BuildInetAddr( struct sockaddr_in *p_sa_in, char *psz_in_addr, int i_port ) } /* Try to convert address directly from in_addr - this will work if * psz_in_addr is dotted decimal. */ +#ifdef SYS_BEOS + else if( (p_sa_in->sin_addr.s_addr = inet_addr( psz_in_addr )) == -1 ) +#else else if( !inet_aton( psz_in_addr, &p_sa_in->sin_addr) ) +#endif { /* The convertion failed: the address is an host name, which needs * to be resolved */ @@ -85,7 +92,7 @@ int BuildInetAddr( struct sockaddr_in *p_sa_in, char *psz_in_addr, int i_port ) } /* Copy the first address of the host in the socket address */ - bcopy( p_hostent->h_addr_list[0], &p_sa_in->sin_addr, p_hostent->h_length); + memmove( &p_sa_in->sin_addr, p_hostent->h_addr_list[0], p_hostent->h_length ); } return( 0 ); } diff --git a/src/misc/plugins.c b/src/misc/plugins.c index c0cb7a3708..ced56d186c 100644 --- a/src/misc/plugins.c +++ b/src/misc/plugins.c @@ -23,14 +23,22 @@ #include /* free(), strtol() */ #include /* sprintf() */ + +#if defined(SYS_LINUX) || defined(SYS_BSD) || defined(SYS_GNU) #include /* dlopen(), dlsym(), dlclose() */ +#endif + +#ifdef SYS_BEOS +#include +#endif + +#include "plugins.h" #define PLUGIN_PATH_COUNT 5 -void * RequestPlugin ( char * psz_mask, char * psz_name ) +int RequestPlugin ( plugin_id_t * p_plugin, char * psz_mask, char * psz_name ) { int i_count, i_length; - void * fd; char * psz_plugin; char * psz_plugin_path[ PLUGIN_PATH_COUNT ] = { @@ -48,23 +56,45 @@ void * RequestPlugin ( char * psz_mask, char * psz_name ) { psz_plugin = malloc( strlen(psz_plugin_path[i_count]) + i_length + 6 ); sprintf( psz_plugin, "%s/%s_%s.so", psz_plugin_path[i_count], psz_mask, psz_name ); - fd = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL ); +#ifdef SYS_BEOS + *p_plugin = load_addon_image( psz_plugin ); +#else /* SYS_BEOS */ + *p_plugin = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL ); +#endif /* SYS_BEOS */ free( psz_plugin ); - if( fd != NULL ) - return( fd ); +#ifdef SYS_BEOS + if( *p_plugin >= 0 ) + return( 0 ); +#else + if( *p_plugin != NULL ) + return( 0 ); +#endif } - return( 0 ); + return( -1 ); } -void TrashPlugin ( void * p_plugin ) +void TrashPlugin ( plugin_id_t plugin ) { - dlclose( p_plugin ); +#ifdef SYS_BEOS + unload_add_on( plugin ); +#else + dlclose( plugin ); +#endif } -void *GetPluginFunction ( void *p_plugin, char *psz_name ) +void * GetPluginFunction ( plugin_id_t plugin, char *psz_name ) { - return( dlsym(p_plugin, psz_name) ); +#ifdef SYS_BEOS + void * p_func; + + if( get_image_symbol( plugin, psz_name, B_SYMBOL_TYPE_TEXT, &p_func ) ) + return( NULL ); + else + return( p_func ); +#else + return( dlsym(plugin, psz_name) ); +#endif } diff --git a/src/spu_decoder/spu_decoder.c b/src/spu_decoder/spu_decoder.c index 3fa4708141..0910b57fbd 100644 --- a/src/spu_decoder/spu_decoder.c +++ b/src/spu_decoder/spu_decoder.c @@ -32,10 +32,10 @@ #include /* for input.h */ #include /* getpid() */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" #include "intf_msg.h" #include "debug.h" /* ASSERT */ diff --git a/src/video_decoder/vdec_idct.c b/src/video_decoder/vdec_idct.c index b0b1aaee00..2d867cd70f 100644 --- a/src/video_decoder/vdec_idct.c +++ b/src/video_decoder/vdec_idct.c @@ -27,10 +27,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* for input.h */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" diff --git a/src/video_decoder/vdec_motion.c b/src/video_decoder/vdec_motion.c index bde293bda1..eff0323b2b 100644 --- a/src/video_decoder/vdec_motion.c +++ b/src/video_decoder/vdec_motion.c @@ -27,10 +27,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* for input.h */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" diff --git a/src/video_decoder/vdec_motion_inner.c b/src/video_decoder/vdec_motion_inner.c index 56689d8de1..7181d558fd 100644 --- a/src/video_decoder/vdec_motion_inner.c +++ b/src/video_decoder/vdec_motion_inner.c @@ -27,10 +27,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* for input.h */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" diff --git a/src/video_decoder/video_decoder.c b/src/video_decoder/video_decoder.c index 03d49892aa..4c7443f8aa 100644 --- a/src/video_decoder/video_decoder.c +++ b/src/video_decoder/video_decoder.c @@ -31,10 +31,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* for input.h */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index 0341868ebe..5c9731834b 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -32,10 +32,10 @@ #include /* sprintf() */ #include /* strerror() */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" #include "plugins.h" #include "video.h" #include "video_output.h" @@ -103,9 +103,8 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window, /* Request an interface plugin */ psz_method = main_GetPszVariable( VOUT_METHOD_VAR, VOUT_DEFAULT_METHOD ); - p_vout->p_vout_plugin = RequestPlugin( "vout", psz_method ); - if( !p_vout->p_vout_plugin ) + if( RequestPlugin( &p_vout->vout_plugin, "vout", psz_method ) < 0 ) { intf_ErrMsg( "error: could not open video plugin vout_%s.so\n", psz_method ); free( p_vout ); @@ -113,12 +112,12 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window, } /* Get plugins */ - p_vout->p_sys_create = GetPluginFunction( p_vout->p_vout_plugin, "vout_SysCreate" ); - p_vout->p_sys_init = GetPluginFunction( p_vout->p_vout_plugin, "vout_SysInit" ); - p_vout->p_sys_end = GetPluginFunction( p_vout->p_vout_plugin, "vout_SysEnd" ); - p_vout->p_sys_destroy = GetPluginFunction( p_vout->p_vout_plugin, "vout_SysDestroy" ); - p_vout->p_sys_manage = GetPluginFunction( p_vout->p_vout_plugin, "vout_SysManage" ); - p_vout->p_sys_display = GetPluginFunction( p_vout->p_vout_plugin, "vout_SysDisplay" ); + p_vout->p_sys_create = GetPluginFunction( p_vout->vout_plugin, "vout_SysCreate" ); + p_vout->p_sys_init = GetPluginFunction( p_vout->vout_plugin, "vout_SysInit" ); + p_vout->p_sys_end = GetPluginFunction( p_vout->vout_plugin, "vout_SysEnd" ); + p_vout->p_sys_destroy = GetPluginFunction( p_vout->vout_plugin, "vout_SysDestroy" ); + p_vout->p_sys_manage = GetPluginFunction( p_vout->vout_plugin, "vout_SysManage" ); + p_vout->p_sys_display = GetPluginFunction( p_vout->vout_plugin, "vout_SysDisplay" ); /* Initialize thread properties - thread id and locks will be initialized * later */ @@ -181,7 +180,7 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window, * own error messages */ if( p_vout->p_sys_create( p_vout, psz_display, i_root_window ) ) { - TrashPlugin( p_vout->p_vout_plugin ); + TrashPlugin( p_vout->vout_plugin ); free( p_vout ); return( NULL ); } @@ -207,7 +206,7 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window, if( p_vout->p_default_font == NULL ) { p_vout->p_sys_destroy( p_vout ); - TrashPlugin( p_vout->p_vout_plugin ); + TrashPlugin( p_vout->vout_plugin ); free( p_vout ); return( NULL ); } @@ -216,7 +215,7 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window, { vout_UnloadFont( p_vout->p_default_font ); p_vout->p_sys_destroy( p_vout ); - TrashPlugin( p_vout->p_vout_plugin ); + TrashPlugin( p_vout->vout_plugin ); free( p_vout ); return( NULL ); } @@ -232,7 +231,7 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window, vout_UnloadFont( p_vout->p_default_font ); vout_UnloadFont( p_vout->p_large_font ); p_vout->p_sys_destroy( p_vout ); - TrashPlugin( p_vout->p_vout_plugin ); + TrashPlugin( p_vout->vout_plugin ); free( p_vout ); return( NULL ); } @@ -1254,7 +1253,7 @@ static void DestroyThread( vout_thread_t *p_vout, int i_status ) p_vout->p_sys_destroy( p_vout ); /* Close plugin */ - TrashPlugin( p_vout->p_vout_plugin ); + TrashPlugin( p_vout->vout_plugin ); /* Free structure */ free( p_vout ); diff --git a/src/video_output/video_yuv.c b/src/video_output/video_yuv.c index 3b8ed95f7a..7113ca662f 100644 --- a/src/video_output/video_yuv.c +++ b/src/video_output/video_yuv.c @@ -32,10 +32,11 @@ #include /* free() */ #include /* strerror() */ +#include "threads.h" #include "common.h" #include "config.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "video.h" #include "video_output.h" #include "video_yuv.h" diff --git a/src/video_parser/video_fifo.c b/src/video_parser/video_fifo.c index 3c48da63b0..d0c4df5578 100644 --- a/src/video_parser/video_fifo.c +++ b/src/video_parser/video_fifo.c @@ -27,10 +27,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* "input.h */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" #include "debug.h" /* XXX?? temporaire, requis par netlist.h */ diff --git a/src/video_parser/video_parser.c b/src/video_parser/video_parser.c index 29b3dabbb3..beab526a7b 100644 --- a/src/video_parser/video_parser.c +++ b/src/video_parser/video_parser.c @@ -31,10 +31,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* "input.h" */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" #include "debug.h" /* XXX?? temporaire, requis par netlist.h */ diff --git a/src/video_parser/vpar_blocks.c b/src/video_parser/vpar_blocks.c index ec14db40c1..a0711fb3a5 100644 --- a/src/video_parser/vpar_blocks.c +++ b/src/video_parser/vpar_blocks.c @@ -27,10 +27,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* "input.h" */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" #include "debug.h" /* XXX?? temporaire, requis par netlist.h */ diff --git a/src/video_parser/vpar_headers.c b/src/video_parser/vpar_headers.c index 41499974ed..d58dba8e78 100644 --- a/src/video_parser/vpar_headers.c +++ b/src/video_parser/vpar_headers.c @@ -28,10 +28,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* "input.h" */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" diff --git a/src/video_parser/vpar_synchro.c b/src/video_parser/vpar_synchro.c index 7c7c18a8ea..200c0fe614 100644 --- a/src/video_parser/vpar_synchro.c +++ b/src/video_parser/vpar_synchro.c @@ -28,10 +28,11 @@ #include /* on BSD, uio.h needs types.h */ #include /* "input.h" */ +#include "threads.h" #include "config.h" #include "common.h" #include "mtime.h" -#include "threads.h" +#include "plugins.h" #include "intf_msg.h" -- 2.39.2