################################################################################
# Environment
-CC=egcc
+CC=gcc
#CC=gcc295
SHELL=/bin/sh
INSTALL=install
#VIDEO += ggi
#VIDEO += glide
# Not yet supported
-#VIDEO += beos
+#VIDEO = beos
#VIDEO += dga
# Fallback method that should always work
VIDEO += dummy
# 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.
LIB += -lpthread -ldl
endif
+ifeq ($SYS),BEOS)
+LIB += -llibroot -llibgame -llibbe
+endif
+
LIB += -lm
#
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;
#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
* 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
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 */
* 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 );
* Boston, MA 02111-1307, USA.
*****************************************************************************/
+
#ifdef SYS_GNU
#include <cthreads.h>
-#else
+#endif
+
+#ifdef SYS_BEOS
+#include <kernel/OS.h>
+#include <kernel/scheduler.h>
+#endif
+
+#if defined(SYS_LINUX) || defined(SYS_BSD)
#include <pthread.h>
#endif
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);
#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
}
#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
}
{
#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
*****************************************************************************/
#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
}
#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
}
#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
*****************************************************************************/
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
}
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
}
#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
}
-
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 */
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "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() */
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "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() */
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "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() */
#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* 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() */
/* 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 );
}
/* 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 );
}
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 );
}
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 );
}
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 );
#include <stdlib.h> /* free() */
#include <netinet/in.h> /* 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"
#include <netinet/in.h> /* 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"
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "input.h" */
+#include "threads.h"
#include "common.h"
#include "config.h"
#include "mtime.h"
-#include "threads.h"
#include "input.h"
#include "input_file.h"
#include <string.h> /* strerror() */
#include <errno.h> /* 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"
#include <errno.h> /* errno */
#include <sys/time.h> /* "input_network.h" */
-#ifdef SYS_BSD
+#if defined(SYS_BSD) || defined(SYS_BEOS)
#include <sys/socket.h> /* struct sockaddr */
#endif
#include <netdb.h> /* servent, getservbyname(), hostent, gethostbyname() */
#include <netinet/in.h> /* 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"
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;
close( p_input->i_handle );
return( 1 );
}
+#endif /* SYS_BEOS */
/*
* Bind the socket
#include <stdlib.h> /* atoi(), malloc(), free() */
#include <netinet/in.h> /* 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"
#include <string.h> /* bzero() */
#include <netinet/in.h> /* ntohs() */
+#include "threads.h"
#include "common.h"
#include "config.h"
#include "mtime.h"
-#include "threads.h"
#include "intf_msg.h"
#include "debug.h"
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
#include <string.h> /* strerror(), bzero() */
#include <stdlib.h> /* free() */
-#ifdef SYS_BSD
+#if defined(SYS_BSD) || defined(SYS_BEOS)
#include <netinet/in.h> /* struct in_addr */
#include <sys/socket.h> /* struct sockaddr */
#endif
+#if defined(SYS_LINUX) || defined(SYS_BSD) || defined(SYS_GNU)
#include <arpa/inet.h> /* inet_ntoa(), inet_aton() */
+#endif
#ifdef SYS_LINUX
#include <sys/ioctl.h> /* ioctl() */
#include <net/if.h> /* 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"
*****************************************************************************/
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 )
intf_Msg("VLANs initialized\n");
return( 0 );
+#endif /* SYS_BEOS */
}
/*****************************************************************************
*****************************************************************************/
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 )
{
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 */
}
/*****************************************************************************
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* for input.h */
+#include "threads.h"
#include "config.h"
#include "common.h"
#include "mtime.h"
-#include "threads.h"
#include "plugins.h"
#include "input.h"
/* 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 );
}
/* 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;
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 );
}
{
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 );
}
UnloadChannels( p_intf );
/* Close plugin */
- TrashPlugin( p_intf->p_intf_plugin );
+ TrashPlugin( p_intf->intf_plugin );
/* Free structure */
free( p_intf );
#include <stdlib.h> /* strtod(), strtol() */
#include <string.h> /* 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"
#include <fcntl.h> /* 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"
#include <string.h> /* strerror() */
#include <unistd.h> /* 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"
/*
* 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): ",
/*
* 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): ",
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <getopt.h> /* getopt() */
#include <signal.h> /* SIGHUP, SIGINT, SIGKILL */
+#include <getopt.h> /* getopt() */
#include <stdio.h> /* sprintf() */
#include <errno.h> /* ENOMEM */
#include <stdlib.h> /* getenv(), strtol(), */
#include <string.h> /* 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"
*****************************************************************************/
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 */
return( 0 );
return( 1 );
+
+#else /* SYS_BEOS */
+ return( 1 );
+#endif /* SYS_BEOS */
}
#endif
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* 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 */
#include <unistd.h> /* select() */
#include <sys/time.h>
+#ifdef SYS_BEOS
+#include <kernel/OS.h>
+#endif
+
#include "common.h"
#include "mtime.h"
*****************************************************************************/
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
* 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
}
/*****************************************************************************
*****************************************************************************/
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 */
#else
usleep( delay );
#endif
+
+#endif /* SYS_BEOS */
}
/*****************************************************************************
*****************************************************************************/
void msleep( mtime_t delay )
{
+#ifdef SYS_BEOS
+ snooze( delay );
+#else /* SYS_BEOS */
+
#ifndef usleep
struct timeval tv_delay;
#else
usleep( delay );
#endif
+
+#endif /* SYS_BEOS */
}
#include <sys/socket.h> /* struct sockaddr */
#endif
-#include <arpa/inet.h> /* htons(), htonl() */
+#if defined(SYS_LINUX) || defined(SYS_BSD) || defined(SYS_GNU)
+#include <arpa/inet.h> /* inet_ntoa(), inet_aton() */
+#endif
+
#ifdef SYS_LINUX
#include <sys/ioctl.h> /* ioctl() */
{
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 */
}
/* 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 */
}
/* 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 );
}
#include <stdlib.h> /* free(), strtol() */
#include <stdio.h> /* sprintf() */
+
+#if defined(SYS_LINUX) || defined(SYS_BSD) || defined(SYS_GNU)
#include <dlfcn.h> /* dlopen(), dlsym(), dlclose() */
+#endif
+
+#ifdef SYS_BEOS
+#include <image.h>
+#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 ] =
{
{
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
}
#include <sys/uio.h> /* for input.h */
#include <unistd.h> /* getpid() */
+#include "threads.h"
#include "config.h"
#include "common.h"
#include "mtime.h"
-#include "threads.h"
#include "intf_msg.h"
#include "debug.h" /* ASSERT */
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* 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"
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* 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"
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* 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"
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* 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"
#include <stdio.h> /* sprintf() */
#include <string.h> /* 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"
/* 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 );
}
/* 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 */
* 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 );
}
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 );
}
{
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 );
}
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 );
}
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 );
#include <stdlib.h> /* free() */
#include <string.h> /* 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"
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "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 */
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "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 */
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "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 */
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "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 <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* "input.h" */
+#include "threads.h"
#include "config.h"
#include "common.h"
#include "mtime.h"
-#include "threads.h"
+#include "plugins.h"
#include "intf_msg.h"