Commit 2733b268 authored by Sam Hocevar's avatar Sam Hocevar

o changement de nom des fonctions sp�cifiques BeOS

 o d�but de l'�clatage de l'audio_output :
   . giclage des variables *dsp* en faveur de *sys*
   . aout_*GetBufInfo renvoie l_bytes pour que video_output.c ne d�pende
    plus de la structure audio_buf_info sp�cifique � <linux/soundcard.h>
   . cr�ation de la m�thode audio 'dummy' qui ne fait rien.
 o nouvelle option --aout acceptant 'dummy' et 'dsp' pour le moment
parent 8e016bb0
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
#define AOUT_FIFO_ISFULL( fifo ) ( ((((fifo).l_end_frame + 1) - (fifo).l_start_frame) & AOUT_FIFO_SIZE) == 0 ) #define AOUT_FIFO_ISFULL( fifo ) ( ((((fifo).l_end_frame + 1) - (fifo).l_start_frame) & AOUT_FIFO_SIZE) == 0 )
/***************************************************************************** /*****************************************************************************
* aout_dsp_t * aout_sys_t
*****************************************************************************/ *****************************************************************************/
typedef struct typedef struct
{ {
...@@ -75,11 +75,11 @@ typedef struct ...@@ -75,11 +75,11 @@ typedef struct
/* Rate of the audio output sound (in Hz) */ /* Rate of the audio output sound (in Hz) */
long l_rate; long l_rate;
/* Buffer information structure, used by aout_dspGetBufInfo() to store the /* Buffer information structure, used by aout_sys_getbufinfo() to store the
* current state of the internal sound card buffer */ * current state of the internal sound card buffer */
audio_buf_info buf_info; audio_buf_info buf_info;
} aout_dsp_t; } aout_sys_t;
/***************************************************************************** /*****************************************************************************
* aout_increment_t * aout_increment_t
...@@ -156,18 +156,38 @@ typedef struct ...@@ -156,18 +156,38 @@ typedef struct
#define AOUT_ADEC_STEREO_FIFO 4 #define AOUT_ADEC_STEREO_FIFO 4
/***************************************************************************** /*****************************************************************************
* aout_thread_t * aout_thread_t : audio output thread descriptor
*****************************************************************************/ *****************************************************************************/
typedef int (aout_sys_open_t) ( aout_sys_t *p_sys );
typedef int (aout_sys_reset_t) ( aout_sys_t *p_sys );
typedef int (aout_sys_setformat_t) ( aout_sys_t *p_sys );
typedef int (aout_sys_setchannels_t) ( aout_sys_t *p_sys );
typedef int (aout_sys_setrate_t) ( aout_sys_t *p_sys );
typedef long (aout_sys_getbufinfo_t) ( aout_sys_t *p_sys );
typedef void (aout_sys_playsamples_t) ( aout_sys_t *p_sys,
byte_t *buffer, int i_size );
typedef void (aout_sys_close_t) ( aout_sys_t *p_sys );
typedef struct aout_thread_s typedef struct aout_thread_s
{ {
vlc_thread_t thread_id; vlc_thread_t thread_id;
boolean_t b_die; boolean_t b_die;
aout_dsp_t dsp; aout_sys_t sys;
vlc_mutex_t fifos_lock; vlc_mutex_t fifos_lock;
aout_fifo_t fifo[ AOUT_MAX_FIFOS ]; aout_fifo_t fifo[ AOUT_MAX_FIFOS ];
/* method-dependant functions */
aout_sys_open_t * p_sys_open;
aout_sys_reset_t * p_sys_reset;
aout_sys_setformat_t * p_sys_setformat;
aout_sys_setchannels_t * p_sys_setchannels;
aout_sys_setrate_t * p_sys_setrate;
aout_sys_getbufinfo_t * p_sys_getbufinfo;
aout_sys_playsamples_t * p_sys_playsamples;
aout_sys_close_t * p_sys_close;
void * buffer; void * buffer;
/* The s32 buffer is used to mix all the audio fifos together before /* The s32 buffer is used to mix all the audio fifos together before
* converting them and storing them in the audio output buffer */ * converting them and storing them in the audio output buffer */
...@@ -184,6 +204,15 @@ typedef struct aout_thread_s ...@@ -184,6 +204,15 @@ typedef struct aout_thread_s
} aout_thread_t; } aout_thread_t;
/* Output methods */
#define AOUT_DUMMY_METHOD 0x0000 /* dummy video output */
#define AOUT_DSP_METHOD 0x0001 /* linux /dev/dsp */
/* Get the fallback method */
#ifdef AUDIO_DSP
#define AOUT_DEFAULT_METHOD "dsp"
#endif
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
......
/***************************************************************************** /*****************************************************************************
* audio_dsp.h : header of the dsp functions library * audio_sys.h : header of the method-dependant functions library
* (c)1999 VideoLAN * (c)1999 VideoLAN
***************************************************************************** *****************************************************************************
* Required headers: * Required headers:
...@@ -10,11 +10,21 @@ ...@@ -10,11 +10,21 @@
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
int aout_dspOpen ( aout_dsp_t *p_dsp ); int aout_DummySysOpen ( aout_sys_t *p_sys );
int aout_dspReset ( aout_dsp_t *p_dsp ); int aout_DummySysReset ( aout_sys_t *p_sys );
int aout_dspSetFormat ( aout_dsp_t *p_dsp ); int aout_DummySysSetFormat ( aout_sys_t *p_sys );
int aout_dspSetChannels( aout_dsp_t *p_dsp ); int aout_DummySysSetChannels ( aout_sys_t *p_sys );
int aout_dspSetRate ( aout_dsp_t *p_dsp ); int aout_DummySysSetRate ( aout_sys_t *p_sys );
void aout_dspGetBufInfo ( aout_dsp_t *p_dsp ); long aout_DummySysGetBufInfo ( aout_sys_t *p_sys );
void aout_dspPlaySamples( aout_dsp_t *p_dsp, byte_t *buffer, int i_size ); void aout_DummySysPlaySamples ( aout_sys_t *p_sys, byte_t *buffer, int i_size );
void aout_dspClose ( aout_dsp_t *p_dsp ); void aout_DummySysClose ( aout_sys_t *p_sys );
#ifdef AUDIO_DSP
int aout_DspSysOpen ( aout_sys_t *p_sys );
int aout_DspSysReset ( aout_sys_t *p_sys );
int aout_DspSysSetFormat ( aout_sys_t *p_sys );
int aout_DspSysSetChannels ( aout_sys_t *p_sys );
int aout_DspSysSetRate ( aout_sys_t *p_sys );
long aout_DspSysGetBufInfo ( aout_sys_t *p_sys );
void aout_DspSysPlaySamples ( aout_sys_t *p_dsp, byte_t *buffer, int i_size );
void aout_DspSysClose ( aout_sys_t *p_sys );
#endif
...@@ -35,8 +35,8 @@ void intf_GGISysDestroy ( p_intf_thread_t p_intf ); ...@@ -35,8 +35,8 @@ void intf_GGISysDestroy ( p_intf_thread_t p_intf );
void intf_GGISysManage ( p_intf_thread_t p_intf ); void intf_GGISysManage ( p_intf_thread_t p_intf );
#endif #endif
#ifdef VIDEO_BEOS #ifdef VIDEO_BEOS
int intf_BeSysCreate ( p_intf_thread_t p_intf ); int intf_BSysCreate ( p_intf_thread_t p_intf );
void intf_BeSysDestroy ( p_intf_thread_t p_intf ); void intf_BSysDestroy ( p_intf_thread_t p_intf );
void intf_BeSysManage ( p_intf_thread_t p_intf ); void intf_BSysManage ( p_intf_thread_t p_intf );
#endif #endif
...@@ -53,11 +53,11 @@ int vout_GGISysManage ( p_vout_thread_t p_vout ); ...@@ -53,11 +53,11 @@ int vout_GGISysManage ( p_vout_thread_t p_vout );
void vout_GGISysDisplay ( p_vout_thread_t p_vout ); void vout_GGISysDisplay ( p_vout_thread_t p_vout );
#endif #endif
#ifdef VIDEO_BEOS #ifdef VIDEO_BEOS
int vout_BeSysCreate ( p_vout_thread_t p_vout, char *psz_display, int i_root_window ); int vout_BSysCreate ( p_vout_thread_t p_vout, char *psz_display, int i_root_window );
int vout_BeSysInit ( p_vout_thread_t p_vout ); int vout_BSysInit ( p_vout_thread_t p_vout );
void vout_BeSysEnd ( p_vout_thread_t p_vout ); void vout_BSysEnd ( p_vout_thread_t p_vout );
void vout_BeSysDestroy ( p_vout_thread_t p_vout ); void vout_BSysDestroy ( p_vout_thread_t p_vout );
int vout_BeSysManage ( p_vout_thread_t p_vout ); int vout_BSysManage ( p_vout_thread_t p_vout );
void vout_BeSysDisplay ( p_vout_thread_t p_vout ); void vout_BSysDisplay ( p_vout_thread_t p_vout );
#endif #endif
/*****************************************************************************
* audio_dsp.c : dsp functions library
* (c)1999 VideoLAN
*****************************************************************************/
/* TODO:
*
* - an aout_dspGetFormats() function
* - dsp inline/static
* - make this library portable (see mpg123)
* - macroify aout_dspPlaySamples &/| aout_dspGetBufInfo ?
*
*/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <fcntl.h> /* open(), O_WRONLY */
#include <sys/ioctl.h> /* ioctl() */
#include <unistd.h> /* write(), close() */
/* SNDCTL_DSP_RESET, SNDCTL_DSP_SETFMT, SNDCTL_DSP_STEREO, SNDCTL_DSP_SPEED, SNDCTL_DSP_GETOSPACE */
#include <sys/soundcard.h>
#include "common.h" /* boolean_t, byte_t */
#include "mtime.h"
#include "vlc_thread.h"
#include "audio_output.h" /* aout_dsp_t */
#include "audio_dsp.h"
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
/*****************************************************************************
* aout_dspOpen: opens the audio device (the digital sound processor)
*****************************************************************************
* - This function opens the dsp as an usual non-blocking write-only file, and
* modifies the p_dsp->i_fd with the file's descriptor.
* - p_dsp->psz_device must be set before calling this function !
*****************************************************************************/
int aout_dspOpen( aout_dsp_t *p_dsp )
{
if ( (p_dsp->i_fd = open( p_dsp->psz_device, O_WRONLY )) < 0 )
{
intf_ErrMsg( "aout error: can't open audio device (%s)\n", p_dsp->psz_device );
return( -1 );
}
return( 0 );
}
/*****************************************************************************
* aout_dspReset: resets the dsp
*****************************************************************************/
int aout_dspReset( aout_dsp_t *p_dsp )
{
if ( ioctl( p_dsp->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 )
{
intf_ErrMsg( "aout error: can't reset audio device (%s)\n", p_dsp->psz_device );
return( -1 );
}
return( 0 );
}
/*****************************************************************************
* aout_dspSetFormat: sets the dsp output format
*****************************************************************************
* This functions tries to initialize the dsp output format with the value
* contained in the dsp structure, and if this value could not be set, the
* default value returned by ioctl is set.
*****************************************************************************/
int aout_dspSetFormat( aout_dsp_t *p_dsp )
{
int i_format;
i_format = p_dsp->i_format;
if ( ioctl( p_dsp->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 )
{
intf_ErrMsg( "aout error: can't set audio output format (%i)\n", p_dsp->i_format );
return( -1 );
}
if ( i_format != p_dsp->i_format )
{
intf_DbgMsg( "aout debug: audio output format not supported (%i)\n", p_dsp->i_format );
p_dsp->i_format = i_format;
}
return( 0 );
}
/*****************************************************************************
* aout_dspSetChannels: sets the dsp's stereo or mono mode
*****************************************************************************
* This function acts just like the previous one...
*****************************************************************************/
int aout_dspSetChannels( aout_dsp_t *p_dsp )
{
boolean_t b_stereo;
b_stereo = p_dsp->b_stereo;
if ( ioctl( p_dsp->i_fd, SNDCTL_DSP_STEREO, &b_stereo ) < 0 )
{
intf_ErrMsg( "aout error: can't set number of audio channels (%i)\n", p_dsp->b_stereo );
return( -1 );
}
if ( b_stereo != p_dsp->b_stereo )
{
intf_DbgMsg( "aout debug: number of audio channels not supported (%i)\n", p_dsp->b_stereo );
p_dsp->b_stereo = b_stereo;
}
return( 0 );
}
/*****************************************************************************
* aout_dspSetRate: sets the dsp's audio output rate
*****************************************************************************
* This function tries to initialize the dsp with the rate contained in the
* dsp structure, but if the dsp doesn't support this value, the function uses
* the value returned by ioctl...
*****************************************************************************/
int aout_dspSetRate( aout_dsp_t *p_dsp )
{
long l_rate;
l_rate = p_dsp->l_rate;
if ( ioctl( p_dsp->i_fd, SNDCTL_DSP_SPEED, &l_rate ) < 0 )
{
intf_ErrMsg( "aout error: can't set audio output rate (%li)\n", p_dsp->l_rate );
return( -1 );
}
if ( l_rate != p_dsp->l_rate )
{
intf_DbgMsg( "aout debug: audio output rate not supported (%li)\n", p_dsp->l_rate );
p_dsp->l_rate = l_rate;
}
return( 0 );
}
/*****************************************************************************
* aout_dspGetBufInfo: buffer status query
*****************************************************************************
* This function fills in the audio_buf_info structure :
* - int fragments : number of available fragments (partially usend ones not
* counted)
* - int fragstotal : total number of fragments allocated
* - int fragsize : size of a fragment in bytes
* - int bytes : available space in bytes (includes partially used fragments)
* Note! 'bytes' could be more than fragments*fragsize
*****************************************************************************/
void aout_dspGetBufInfo( aout_dsp_t *p_dsp )
{
ioctl( p_dsp->i_fd, SNDCTL_DSP_GETOSPACE, &p_dsp->buf_info );
}
/*****************************************************************************
* aout_dspPlaySamples: plays a sound samples buffer
*****************************************************************************
* This function writes a buffer of i_length bytes in the dsp
*****************************************************************************/
void aout_dspPlaySamples( aout_dsp_t *p_dsp, byte_t *buffer, int i_size )
{
write( p_dsp->i_fd, buffer, i_size );
}
/*****************************************************************************
* aout_dspClose: closes the dsp audio device
*****************************************************************************/
void aout_dspClose( aout_dsp_t *p_dsp )
{
close( p_dsp->i_fd );
}
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */ #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
#include "audio_output.h" #include "audio_output.h"
#include "audio_dsp.h" #include "audio_sys.h"
#include "main.h" #include "main.h"
/***************************************************************************** /*****************************************************************************
...@@ -62,6 +62,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m ...@@ -62,6 +62,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m
aout_thread_t *aout_CreateThread( int *pi_status ) aout_thread_t *aout_CreateThread( int *pi_status )
{ {
aout_thread_t * p_aout; /* thread descriptor */ aout_thread_t * p_aout; /* thread descriptor */
char * psz_method;
// int i_status; /* thread status */ // int i_status; /* thread status */
/* Allocate descriptor */ /* Allocate descriptor */
...@@ -71,57 +72,91 @@ aout_thread_t *aout_CreateThread( int *pi_status ) ...@@ -71,57 +72,91 @@ aout_thread_t *aout_CreateThread( int *pi_status )
return( NULL ); return( NULL );
} }
/* initialize method-dependent functions */
psz_method = main_GetPszVariable( AOUT_METHOD_VAR, AOUT_DEFAULT_METHOD );
if( !strcmp(psz_method, "dummy") )
{
p_aout->p_sys_open = aout_DummySysOpen;
p_aout->p_sys_reset = aout_DummySysReset;
p_aout->p_sys_setformat = aout_DummySysSetFormat;
p_aout->p_sys_setchannels = aout_DummySysSetChannels;
p_aout->p_sys_setrate = aout_DummySysSetRate;
p_aout->p_sys_getbufinfo = aout_DummySysGetBufInfo;
p_aout->p_sys_playsamples = aout_DummySysPlaySamples;
p_aout->p_sys_close = aout_DummySysClose;
}
#ifdef VIDEO_X11
else if( !strcmp(psz_method, "dsp") )
{
p_aout->p_sys_open = aout_DspSysOpen;
p_aout->p_sys_reset = aout_DspSysReset;
p_aout->p_sys_setformat = aout_DspSysSetFormat;
p_aout->p_sys_setchannels = aout_DspSysSetChannels;
p_aout->p_sys_setrate = aout_DspSysSetRate;
p_aout->p_sys_getbufinfo = aout_DspSysGetBufInfo;
p_aout->p_sys_playsamples = aout_DspSysPlaySamples;
p_aout->p_sys_close = aout_DspSysClose;
}
#endif
else
{
intf_ErrMsg( "error: requested audio output method not available\n" );
free( p_aout );
return( NULL );
}
//???? kludge to initialize some audio parameters - place this section somewhere //???? kludge to initialize some audio parameters - place this section somewhere
//???? else //???? else
p_aout->dsp.i_format = AOUT_DEFAULT_FORMAT; p_aout->sys.i_format = AOUT_DEFAULT_FORMAT;
p_aout->dsp.psz_device = main_GetPszVariable( AOUT_DSP_VAR, AOUT_DSP_DEFAULT ); p_aout->sys.psz_device = main_GetPszVariable( AOUT_DSP_VAR, AOUT_DSP_DEFAULT );
p_aout->dsp.b_stereo = main_GetIntVariable( AOUT_STEREO_VAR, AOUT_STEREO_DEFAULT ); p_aout->sys.b_stereo = main_GetIntVariable( AOUT_STEREO_VAR, AOUT_STEREO_DEFAULT );
p_aout->dsp.l_rate = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT ); p_aout->sys.l_rate = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT );
// ???? end of kludge // ???? end of kludge
/* /*
* Initialize DSP * Initialize DSP
*/ */
if ( aout_dspOpen( &p_aout->dsp ) ) if ( p_aout->p_sys_open( &p_aout->sys ) )
{ {
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
if ( aout_dspReset( &p_aout->dsp ) ) if ( p_aout->p_sys_reset( &p_aout->sys ) )
{ {
aout_dspClose( &p_aout->dsp ); p_aout->p_sys_close( &p_aout->sys );
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
if ( aout_dspSetFormat( &p_aout->dsp ) ) if ( p_aout->p_sys_setformat( &p_aout->sys ) )
{ {
aout_dspClose( &p_aout->dsp ); p_aout->p_sys_close( &p_aout->sys );
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
if ( aout_dspSetChannels( &p_aout->dsp ) ) if ( p_aout->p_sys_setchannels( &p_aout->sys ) )
{ {
aout_dspClose( &p_aout->dsp ); p_aout->p_sys_close( &p_aout->sys );
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
if ( aout_dspSetRate( &p_aout->dsp ) ) if ( p_aout->p_sys_setrate( &p_aout->sys ) )
{ {
aout_dspClose( &p_aout->dsp ); p_aout->p_sys_close( &p_aout->sys );
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
intf_DbgMsg("aout debug: audio device (%s) opened (format=%i, stereo=%i, rate=%li)\n", intf_DbgMsg("aout debug: audio device (%s) opened (format=%i, stereo=%i, rate=%li)\n",
p_aout->dsp.psz_device, p_aout->sys.psz_device,
p_aout->dsp.i_format, p_aout->sys.i_format,
p_aout->dsp.b_stereo, p_aout->dsp.l_rate); p_aout->sys.b_stereo, p_aout->sys.l_rate);
//?? maybe it would be cleaner to change SpawnThread prototype //?? maybe it would be cleaner to change SpawnThread prototype
//?? see vout to handle status correctly - however, it is not critical since //?? see vout to handle status correctly - however, it is not critical since
//?? this thread is only called in main is all calls are blocking //?? this thread is only called in main and all calls are blocking
if( aout_SpawnThread( p_aout ) ) if( aout_SpawnThread( p_aout ) )
{ {
aout_dspClose( &p_aout->dsp ); p_aout->p_sys_close( &p_aout->sys );
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
...@@ -156,16 +191,16 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) ...@@ -156,16 +191,16 @@ static int aout_SpawnThread( aout_thread_t * p_aout )
/* Compute the size (in audio units) of the audio output buffer. Although /* Compute the size (in audio units) of the audio output buffer. Although
* AOUT_BUFFER_DURATION is given in microseconds, the output rate is given * AOUT_BUFFER_DURATION is given in microseconds, the output rate is given
* in Hz, that's why we need to divide by 10^6 microseconds (1 second) */ * in Hz, that's why we need to divide by 10^6 microseconds (1 second) */
p_aout->l_units = (long)( ((s64)p_aout->dsp.l_rate * AOUT_BUFFER_DURATION) / 1000000 ); p_aout->l_units = (long)( ((s64)p_aout->sys.l_rate * AOUT_BUFFER_DURATION) / 1000000 );
p_aout->l_msleep = (long)( ((s64)p_aout->l_units * 1000000) / (s64)p_aout->dsp.l_rate ); p_aout->l_msleep = (long)( ((s64)p_aout->l_units * 1000000) / (s64)p_aout->sys.l_rate );
/* Make aout_thread point to the right thread function, and compute the /* Make aout_thread point to the right thread function, and compute the
* byte size of the audio output buffer */ * byte size of the audio output buffer */
switch ( p_aout->dsp.b_stereo ) switch ( p_aout->sys.b_stereo )
{ {
/* Audio output is mono */ /* Audio output is mono */
case 0: case 0:
switch ( p_aout->dsp.i_format ) switch ( p_aout->sys.i_format )
{ {
case AFMT_U8: case AFMT_U8:
l_bytes = 1 * sizeof(u8) * p_aout->l_units; l_bytes = 1 * sizeof(u8) * p_aout->l_units;
...@@ -191,14 +226,14 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) ...@@ -191,14 +226,14 @@ static int aout_SpawnThread( aout_thread_t * p_aout )
default: default:
intf_ErrMsg("aout error: unknown audio output format (%i)\n", intf_ErrMsg("aout error: unknown audio output format (%i)\n",
p_aout->dsp.i_format); p_aout->sys.i_format);
return( -1 ); return( -1 );
} }
break; break;
/* Audio output is stereo */ /* Audio output is stereo */
case 1: case 1:
switch ( p_aout->dsp.i_format ) switch ( p_aout->sys.i_format )
{ {
case AFMT_U8: case AFMT_U8:
l_bytes = 2 * sizeof(u8) * p_aout->l_units; l_bytes = 2 * sizeof(u8) * p_aout->l_units;
...@@ -224,14 +259,14 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) ...@@ -224,14 +259,14 @@ static int aout_SpawnThread( aout_thread_t * p_aout )
default: default:
intf_ErrMsg("aout error: unknown audio output format (%i)\n", intf_ErrMsg("aout error: unknown audio output format (%i)\n",
p_aout->dsp.i_format); p_aout->sys.i_format);
return( -1 ); return( -1 );
} }
break; break;
default: default:
intf_ErrMsg("aout error: unknown number of audio channels (%i)\n", intf_ErrMsg("aout error: unknown number of audio channels (%i)\n",
p_aout->dsp.b_stereo + 1); p_aout->sys.b_stereo + 1);
return( -1 ); return( -1 );
} }
...@@ -242,7 +277,7 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) ...@@ -242,7 +277,7 @@ static int aout_SpawnThread( aout_thread_t * p_aout )
intf_ErrMsg("aout error: not enough memory to create the output buffer\n"); intf_ErrMsg("aout error: not enough memory to create the output buffer\n");
return( -1 ); return( -1 );
} }
if ( (p_aout->s32_buffer = (s32 *)calloc(p_aout->l_units, sizeof(s32) << p_aout->dsp.b_stereo)) == NULL ) if ( (p_aout->s32_buffer = (s32 *)calloc(p_aout->l_units, sizeof(s32) << p_aout->sys.b_stereo)) == NULL )
{ {
intf_ErrMsg("aout error: not enough memory to create the s32 output buffer\n"); intf_ErrMsg("aout error: not enough memory to create the s32 output buffer\n");
free( p_aout->buffer ); free( p_aout->buffer );
...@@ -284,8 +319,8 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status ) ...@@ -284,8 +319,8 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
free( p_aout->s32_buffer ); free( p_aout->s32_buffer );
/* Free the structure */ /* Free the structure */
aout_dspClose( &p_aout->dsp ); p_aout->p_sys_close( &p_aout->sys );
intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->dsp.psz_device); intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->sys.psz_device);
free( p_aout ); free( p_aout );
} }
...@@ -327,7 +362,7 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo ) ...@@ -327,7 +362,7 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
p_aout->fifo[i_fifo].buffer = p_fifo->buffer; p_aout->fifo[i_fifo].buffer = p_fifo->buffer;
p_aout->fifo[i_fifo].l_unit = 0; p_aout->fifo[i_fifo].l_unit = 0;
InitializeIncrement( &p_aout->fifo[i_fifo].unit_increment, p_fifo->l_rate, p_aout->dsp.l_rate ); InitializeIncrement( &p_aout->fifo[i_fifo].unit_increment, p_fifo->l_rate, p_aout->sys.l_rate );
p_aout->fifo[i_fifo].l_units = p_fifo->l_units; p_aout->fifo[i_fifo].l_units = p_fifo->l_units;
break; break;
...@@ -495,11 +530,11 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m ...@@ -495,11 +530,11 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m
l_rate = p_fifo->l_rate + ((aout_date - p_fifo->date[p_fifo->l_start_frame]) / 256); l_rate = p_fifo->l_rate + ((aout_date - p_fifo->date[p_fifo->l_start_frame]) / 256);
// fprintf( stderr, "aout debug: %lli (%li);\n", aout_date - p_fifo->date[p_fifo->l_start_frame], l_rate ); // fprintf( stderr, "aout debug: %lli (%li);\n", aout_date - p_fifo->date[p_fifo->l_start_frame], l_rate );
InitializeIncrement( &p_fifo->unit_increment, l_rate, p_aout->dsp.l_rate ); InitializeIncrement( &p_fifo->unit_increment, l_rate, p_aout->sys.l_rate );
p_fifo->l_units = (((l_units - (p_fifo->l_unit - p_fifo->l_units = (((l_units - (p_fifo->l_unit -
(p_fifo->l_start_frame * (p_fifo->l_frame_size >> p_fifo->b_stereo)))) (p_fifo->l_start_frame * (p_fifo->l_frame_size >> p_fifo->b_stereo))))
* p_aout->dsp.l_rate) / l_rate) + 1; * p_aout->sys.l_rate) / l_rate) + 1;
/* We release the lock before leaving */ /* We release the lock before leaving */
vlc_mutex_unlock( &p_fifo->data_lock ); vlc_mutex_unlock( &p_fifo->data_lock );
...@@ -550,7 +585,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -550,7 +585,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units ) if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
{ {
l_buffer = 0; l_buffer = 0;
while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->dsp.b_stereo == 1 */ while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->sys.b_stereo == 1 */
{ {
p_aout->s32_buffer[l_buffer++] += p_aout->s32_buffer[l_buffer++] +=
(s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
...@@ -563,7 +598,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -563,7 +598,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
else else
{ {
l_buffer = 0; l_buffer = 0;
while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->dsp.b_stereo == 1 */ while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->sys.b_stereo == 1 */
{ {
p_aout->s32_buffer[l_buffer++] += p_aout->s32_buffer[l_buffer++] +=
(s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
...@@ -581,7 +616,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -581,7 +616,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units ) if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
{ {
l_buffer = 0; l_buffer = 0;
while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->dsp.b_stereo == 1 */ while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->sys.b_stereo == 1 */
{ {
p_aout->s32_buffer[l_buffer++] += p_aout->s32_buffer[l_buffer++] +=
(s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
...@@ -594,7 +629,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -594,7 +629,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
else else
{ {
l_buffer = 0; l_buffer = 0;
while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->dsp.b_stereo */ while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->sys.b_stereo */
{ {
p_aout->s32_buffer[l_buffer++] += p_aout->s32_buffer[l_buffer++] +=
(s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
...@@ -624,7 +659,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -624,7 +659,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
{ {
if ( !p_aout->fifo[i_fifo].b_next_frame ) if ( !p_aout->fifo[i_fifo].b_next_frame )
{ {
if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->dsp.l_rate))) ) if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->sys.l_rate))) )
{ {
break; break;
} }
...@@ -632,7 +667,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -632,7 +667,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
if ( p_aout->fifo[i_fifo].l_units > l_units ) if ( p_aout->fifo[i_fifo].l_units > l_units )
{ {
l_buffer_limit = p_aout->l_units << 1; /* p_aout->dsp.b_stereo == 1 */ l_buffer_limit = p_aout->l_units << 1; /* p_aout->sys.b_stereo == 1 */
while ( l_buffer < l_buffer_limit ) while ( l_buffer < l_buffer_limit )
{ {
p_aout->s32_buffer[l_buffer++] += p_aout->s32_buffer[l_buffer++] +=
...@@ -654,7 +689,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -654,7 +689,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
else else
{ {
l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1); l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
/* p_aout->dsp.b_stereo == 1 */ /* p_aout->sys.b_stereo == 1 */
while ( l_buffer < l_buffer_limit ) while ( l_buffer < l_buffer_limit )
{ {
p_aout->s32_buffer[l_buffer++] += p_aout->s32_buffer[l_buffer++] +=
...@@ -701,7 +736,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -701,7 +736,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
{ {
if ( !p_aout->fifo[i_fifo].b_next_frame ) if ( !p_aout->fifo[i_fifo].b_next_frame )
{ {
if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->dsp.l_rate))) ) if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->sys.l_rate))) )
{ {
break; break;
} }
...@@ -709,7 +744,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -709,7 +744,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
if ( p_aout->fifo[i_fifo].l_units > l_units ) if ( p_aout->fifo[i_fifo].l_units > l_units )
{ {
l_buffer_limit = p_aout->l_units << 1; /* p_aout->dsp.b_stereo == 1 */ l_buffer_limit = p_aout->l_units << 1; /* p_aout->sys.b_stereo == 1 */
while ( l_buffer < l_buffer_limit ) while ( l_buffer < l_buffer_limit )
{ {
p_aout->s32_buffer[l_buffer++] += p_aout->s32_buffer[l_buffer++] +=
...@@ -731,7 +766,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -731,7 +766,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
else else
{ {
l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1); l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
/* p_aout->dsp.b_stereo == 1 */ /* p_aout->sys.b_stereo == 1 */
while ( l_buffer < l_buffer_limit ) while ( l_buffer < l_buffer_limit )
{ {
p_aout->s32_buffer[l_buffer++] += p_aout->s32_buffer[l_buffer++] +=
...@@ -769,7 +804,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -769,7 +804,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
} }
vlc_mutex_unlock( &p_aout->fifos_lock ); vlc_mutex_unlock( &p_aout->fifos_lock );
l_buffer_limit = p_aout->l_units << 1; /* p_aout->dsp.b_stereo == 1 */ l_buffer_limit = p_aout->l_units << 1; /* p_aout->sys.b_stereo == 1 */
for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ ) for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
{ {
...@@ -777,10 +812,9 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -777,10 +812,9 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
p_aout->s32_buffer[l_buffer] = 0; p_aout->s32_buffer[l_buffer] = 0;
} }
aout_dspGetBufInfo( &p_aout->dsp ); l_bytes = p_aout->p_sys_getbufinfo( &p_aout->sys );
l_bytes = (p_aout->dsp.buf_info.fragstotal * p_aout->dsp.buf_info.fragsize) - p_aout->dsp.buf_info.bytes; p_aout->date = mdate() + ((((mtime_t)(l_bytes / 4)) * 1000000) / ((mtime_t)p_aout->sys.l_rate)); /* sizeof(s16) << p_aout->sys.b_stereo == 4 */
p_aout->date = mdate() + ((((mtime_t)(l_bytes / 4)) * 1000000) / ((mtime_t)p_aout->dsp.l_rate)); /* sizeof(s16) << p_aout->dsp.b_stereo == 4 */ p_aout->p_sys_playsamples( &p_aout->sys, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(s16) );
aout_dspPlaySamples( &p_aout->dsp, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(s16) );
if ( l_bytes > (l_buffer_limit * sizeof(s16)) ) if ( l_bytes > (l_buffer_limit * sizeof(s16)) )
{ {
msleep( p_aout->l_msleep ); msleep( p_aout->l_msleep );
......
...@@ -130,14 +130,14 @@ intf_thread_t* intf_Create( void ) ...@@ -130,14 +130,14 @@ intf_thread_t* intf_Create( void )
#ifdef VIDEO_BEOS #ifdef VIDEO_BEOS
else if( !strcmp(psz_method, "beos") ) else if( !strcmp(psz_method, "beos") )
{ {
p_intf->p_sys_create = intf_BeSysCreate; p_intf->p_sys_create = intf_BSysCreate;
p_intf->p_sys_manage = intf_BeSysManage; p_intf->p_sys_manage = intf_BSysManage;
p_intf->p_sys_destroy = intf_BeSysDestroy; p_intf->p_sys_destroy = intf_BSysDestroy;
} }
#endif #endif
else else
{ {
intf_ErrMsg( "error: video output method not available\n" ); intf_ErrMsg( "error: requested video output method not available\n" );
free( p_intf ); free( p_intf );
return( NULL ); return( NULL );
} }
......
...@@ -26,47 +26,6 @@ ...@@ -26,47 +26,6 @@
*****************************************************************************/ *****************************************************************************/
#include "vlc.h" #include "vlc.h"
#include <sys/stat.h> #include <sys/stat.h>
/*??#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/soundcard.h>
#include <sys/uio.h>
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h"
#include "intf_msg.h"
#include "input.h"
#include "input_ctrl.h"
#include "input_vlan.h"
#include "input_psi.h"
#include "input_netlist.h"
#include "decoder_fifo.h"
#include "audio_output.h"
#include "audio_decoder.h"
#include "video.h"
#include "video_output.h"
#include "video_graphics.h"
#include "video_decoder.h"
#include "xconsole.h"
#include "interface.h"
#include "intf_cmd.h"
#include "control.h"
#include "intf_ctrl.h"
#include "pgm_data.h"
*/
/* /*
* Local prototypes * Local prototypes
...@@ -382,8 +341,8 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv ) ...@@ -382,8 +341,8 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
} }
close( i_fd ); close( i_fd );
/* Now we can work out how many output units we can compute with the fifo */ /* Now we can work out how many output units we can compute with the fifo */
fifo.l_units = (long)(((s64)fifo.l_units*(s64)p_main->p_aout->dsp.l_rate)/(s64)fifo.l_rate); fifo.l_units = (long)(((s64)fifo.l_units*(s64)p_main->p_aout->sys.l_rate)/(s64)fifo.l_rate);
/* Create the fifo */ /* Create the fifo */
if ( aout_CreateFifo(p_main->p_aout, &fifo) == NULL ) if ( aout_CreateFifo(p_main->p_aout, &fifo) == NULL )
......
...@@ -144,12 +144,12 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window, ...@@ -144,12 +144,12 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window,
#endif #endif
#ifdef VIDEO_BEOS #ifdef VIDEO_BEOS
case VOUT_BEOS_METHOD: case VOUT_BEOS_METHOD:
p_vout->p_sys_create = vout_BeSysCreate; p_vout->p_sys_create = vout_BSysCreate;
p_vout->p_sys_init = vout_BeSysInit; p_vout->p_sys_init = vout_BSysInit;
p_vout->p_sys_end = vout_BeSysEnd; p_vout->p_sys_end = vout_BSysEnd;
p_vout->p_sys_destroy = vout_BeSysDestroy; p_vout->p_sys_destroy = vout_BSysDestroy;
p_vout->p_sys_manage = vout_BeSysManage; p_vout->p_sys_manage = vout_BSysManage;
p_vout->p_sys_display = vout_BeSysDisplay; p_vout->p_sys_display = vout_BSysDisplay;
break; break;
#endif #endif
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment