Commit 2ebf6c03 authored by Sam Hocevar's avatar Sam Hocevar

o renommage arbitraire et totalitaire de idctmmx.S en vdec_idctmmx.S

 o correction d'une typo d�bile dans audio_output au commit pr�c�dent
 o b_stereo est remplac� par i_channels
 o suppression de la structure aout_dsp_t dont les membres d�pendant
  de l'output se retrouve dans aout_*_sys_t, et les autres directement
  dans aout_thread_t, on se fait pas chier.
parent 2733b268
...@@ -326,10 +326,10 @@ C_OBJ = $(interface_obj) \ ...@@ -326,10 +326,10 @@ C_OBJ = $(interface_obj) \
ifeq ($(ARCH),X86) ifeq ($(ARCH),X86)
ifeq ($(MMX), YES) ifeq ($(MMX), YES)
ifeq ($(DECODER),new) ifeq ($(DECODER),new)
ASM_OBJ = video_decoder/idctmmx.o \ ASM_OBJ = video_decoder/vdec_idctmmx.o \
video_output/video_yuv_mmx.o video_output/video_yuv_mmx.o
else else
ASM_OBJ = video_decoder_ref/idctmmx.o \ ASM_OBJ = video_decoder_ref/vdec_idctmmx.o \
video_output/video_yuv_mmx.o video_output/video_yuv_mmx.o
endif endif
endif endif
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
/* Default output device. You probably should not change this. */ /* Default output device. You probably should not change this. */
#define AOUT_DEFAULT_DEVICE "/dev/dsp" #define AOUT_DEFAULT_DEVICE "/dev/dsp"
/* Default audio output format (AFMT_S16_NE = Native Endianess) */ /* Default audio output format (AOUT_FMT_S16_NE = Native Endianess) */
#define AOUT_DEFAULT_FORMAT AFMT_S16_NE #define AOUT_DEFAULT_FORMAT AOUT_FMT_S16_NE
/* Default stereo mode (0 stands for mono, 1 for stereo) */ /* Default stereo mode (0 stands for mono, 1 for stereo) */
#define AOUT_DEFAULT_STEREO 1 #define AOUT_DEFAULT_STEREO 1
...@@ -59,28 +59,6 @@ ...@@ -59,28 +59,6 @@
#define AOUT_FIFO_ISEMPTY( fifo ) ( (fifo).l_end_frame == (fifo).i_start_frame ) #define AOUT_FIFO_ISEMPTY( fifo ) ( (fifo).l_end_frame == (fifo).i_start_frame )
#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_sys_t
*****************************************************************************/
typedef struct
{
/* Path to the audio output device (default is set to "/dev/dsp") */
char * psz_device;
int i_fd;
/* Format of the audio output samples (see <sys/soundcard.h>) */
int i_format;
/* Following boolean is set to 0 if output sound is mono, 1 if stereo */
boolean_t b_stereo;
/* Rate of the audio output sound (in Hz) */
long l_rate;
/* Buffer information structure, used by aout_sys_getbufinfo() to store the
* current state of the internal sound card buffer */
audio_buf_info buf_info;
} aout_sys_t;
/***************************************************************************** /*****************************************************************************
* aout_increment_t * aout_increment_t
***************************************************************************** *****************************************************************************
...@@ -118,7 +96,7 @@ typedef struct ...@@ -118,7 +96,7 @@ typedef struct
int i_type; int i_type;
boolean_t b_die; boolean_t b_die;
boolean_t b_stereo; int i_channels;
long l_rate; long l_rate;
vlc_mutex_t data_lock; vlc_mutex_t data_lock;
...@@ -158,23 +136,21 @@ typedef struct ...@@ -158,23 +136,21 @@ typedef struct
/***************************************************************************** /*****************************************************************************
* aout_thread_t : audio output thread descriptor * aout_thread_t : audio output thread descriptor
*****************************************************************************/ *****************************************************************************/
typedef int (aout_sys_open_t) ( aout_sys_t *p_sys ); typedef int (aout_sys_open_t) ( p_aout_thread_t p_aout );
typedef int (aout_sys_reset_t) ( aout_sys_t *p_sys ); typedef int (aout_sys_reset_t) ( p_aout_thread_t p_aout );
typedef int (aout_sys_setformat_t) ( aout_sys_t *p_sys ); typedef int (aout_sys_setformat_t) ( p_aout_thread_t p_aout );
typedef int (aout_sys_setchannels_t) ( aout_sys_t *p_sys ); typedef int (aout_sys_setchannels_t) ( p_aout_thread_t p_aout );
typedef int (aout_sys_setrate_t) ( aout_sys_t *p_sys ); typedef int (aout_sys_setrate_t) ( p_aout_thread_t p_aout );
typedef long (aout_sys_getbufinfo_t) ( aout_sys_t *p_sys ); typedef long (aout_sys_getbufinfo_t) ( p_aout_thread_t p_aout );
typedef void (aout_sys_playsamples_t) ( aout_sys_t *p_sys, typedef void (aout_sys_playsamples_t) ( p_aout_thread_t p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
typedef void (aout_sys_close_t) ( aout_sys_t *p_sys ); typedef void (aout_sys_close_t) ( p_aout_thread_t p_aout );
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_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 ];
...@@ -202,6 +178,22 @@ typedef struct aout_thread_s ...@@ -202,6 +178,22 @@ typedef struct aout_thread_s
* will be played */ * will be played */
mtime_t date; mtime_t date;
/* Path to the audio output device (default is set to "/dev/dsp") */
char * psz_device;
int i_fd;
/* Format of the audio output samples */
int i_format;
/* Number of channels */
int i_channels;
/* Rate and gain of the audio output sound (in Hz) */
long l_rate;
long l_gain;
/* there might be some useful private structure, such as audio_buf_info
* for the OSS output */
p_aout_sys_t p_sys;
} aout_thread_t; } aout_thread_t;
/* Output methods */ /* Output methods */
...@@ -213,6 +205,21 @@ typedef struct aout_thread_s ...@@ -213,6 +205,21 @@ typedef struct aout_thread_s
#define AOUT_DEFAULT_METHOD "dsp" #define AOUT_DEFAULT_METHOD "dsp"
#endif #endif
/* Those are from <linux/soundcard.h> but are needed because of formats
* on other platforms */
#define AOUT_FMT_U8 0x00000008
#define AOUT_FMT_S16_LE 0x00000010 /* Little endian signed 16 */
#define AOUT_FMT_S16_BE 0x00000020 /* Big endian signed 16 */
#define AOUT_FMT_S8 0x00000040
#define AOUT_FMT_U16_LE 0x00000080 /* Little endian U16 */
#define AOUT_FMT_U16_BE 0x00000100 /* Big endian U16 */
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define AOUT_FMT_S16_NE AOUT_FMT_S16_LE
#elif __BYTE_ORDER == __BIG_ENDIAN
#define AOUT_FMT_S16_NE AOUT_FMT_S16_BE
#endif
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
......
...@@ -10,21 +10,21 @@ ...@@ -10,21 +10,21 @@
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
int aout_DummySysOpen ( aout_sys_t *p_sys ); int aout_DummySysOpen ( aout_thread_t *p_aout );
int aout_DummySysReset ( aout_sys_t *p_sys ); int aout_DummySysReset ( aout_thread_t *p_aout );
int aout_DummySysSetFormat ( aout_sys_t *p_sys ); int aout_DummySysSetFormat ( aout_thread_t *p_aout );
int aout_DummySysSetChannels ( aout_sys_t *p_sys ); int aout_DummySysSetChannels ( aout_thread_t *p_aout );
int aout_DummySysSetRate ( aout_sys_t *p_sys ); int aout_DummySysSetRate ( aout_thread_t *p_aout );
long aout_DummySysGetBufInfo ( aout_sys_t *p_sys ); long aout_DummySysGetBufInfo ( aout_thread_t *p_aout );
void aout_DummySysPlaySamples ( aout_sys_t *p_sys, byte_t *buffer, int i_size ); void aout_DummySysPlaySamples ( aout_thread_t *p_aout, byte_t *buffer, int i_size );
void aout_DummySysClose ( aout_sys_t *p_sys ); void aout_DummySysClose ( aout_thread_t *p_aout );
#ifdef AUDIO_DSP #ifdef AUDIO_DSP
int aout_DspSysOpen ( aout_sys_t *p_sys ); int aout_DspSysOpen ( aout_thread_t *p_aout );
int aout_DspSysReset ( aout_sys_t *p_sys ); int aout_DspSysReset ( aout_thread_t *p_aout );
int aout_DspSysSetFormat ( aout_sys_t *p_sys ); int aout_DspSysSetFormat ( aout_thread_t *p_aout );
int aout_DspSysSetChannels ( aout_sys_t *p_sys ); int aout_DspSysSetChannels ( aout_thread_t *p_aout );
int aout_DspSysSetRate ( aout_sys_t *p_sys ); int aout_DspSysSetRate ( aout_thread_t *p_aout );
long aout_DspSysGetBufInfo ( aout_sys_t *p_sys ); long aout_DspSysGetBufInfo ( aout_thread_t *p_aout );
void aout_DspSysPlaySamples ( aout_sys_t *p_dsp, byte_t *buffer, int i_size ); void aout_DspSysPlaySamples ( aout_thread_t *p_aout, byte_t *buffer, int i_size );
void aout_DspSysClose ( aout_sys_t *p_sys ); void aout_DspSysClose ( aout_thread_t *p_aout );
#endif #endif
...@@ -58,8 +58,10 @@ typedef struct input_cfg_s * p_input_cfg_t; ...@@ -58,8 +58,10 @@ typedef struct input_cfg_s * p_input_cfg_t;
/* Audio */ /* Audio */
struct aout_thread_s; struct aout_thread_s;
struct aout_sys_s;
typedef struct aout_thread_s * p_aout_thread_t; typedef struct aout_thread_s * p_aout_thread_t;
typedef struct aout_sys_s * p_aout_sys_t;
/* Video */ /* Video */
struct vout_thread_s; struct vout_thread_s;
......
...@@ -181,7 +181,7 @@ static int InitThread( ac3dec_thread_t * p_ac3dec ) ...@@ -181,7 +181,7 @@ static int InitThread( ac3dec_thread_t * p_ac3dec )
vlc_mutex_unlock( &p_ac3dec->fifo.data_lock ); vlc_mutex_unlock( &p_ac3dec->fifo.data_lock );
aout_fifo.i_type = AOUT_ADEC_STEREO_FIFO; aout_fifo.i_type = AOUT_ADEC_STEREO_FIFO;
aout_fifo.b_stereo = 1; aout_fifo.i_channels = 2;
aout_fifo.l_frame_size = AC3DEC_FRAME_SIZE; aout_fifo.l_frame_size = AC3DEC_FRAME_SIZE;
......
...@@ -740,13 +740,13 @@ static int InitThread( adec_thread_t * p_adec ) ...@@ -740,13 +740,13 @@ static int InitThread( adec_thread_t * p_adec )
{ {
intf_DbgMsg("adec debug: mode == mono\n"); intf_DbgMsg("adec debug: mode == mono\n");
aout_fifo.i_type = AOUT_ADEC_MONO_FIFO; aout_fifo.i_type = AOUT_ADEC_MONO_FIFO;
aout_fifo.b_stereo = 0; aout_fifo.i_channels = 1;
} }
else else
{ {
intf_DbgMsg("adec debug: mode == stereo\n"); intf_DbgMsg("adec debug: mode == stereo\n");
aout_fifo.i_type = AOUT_ADEC_STEREO_FIFO; aout_fifo.i_type = AOUT_ADEC_STEREO_FIFO;
aout_fifo.b_stereo = 1; aout_fifo.i_channels = 2;
} }
/* Checking the sampling frequency */ /* Checking the sampling frequency */
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
*****************************************************************************/ *****************************************************************************/
#include <unistd.h> #include <unistd.h>
#include <sys/soundcard.h>
#include <stdio.h> /* "intf_msg.h" */ #include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* calloc(), malloc(), free() */ #include <stdlib.h> /* calloc(), malloc(), free() */
...@@ -86,7 +85,7 @@ aout_thread_t *aout_CreateThread( int *pi_status ) ...@@ -86,7 +85,7 @@ aout_thread_t *aout_CreateThread( int *pi_status )
p_aout->p_sys_playsamples = aout_DummySysPlaySamples; p_aout->p_sys_playsamples = aout_DummySysPlaySamples;
p_aout->p_sys_close = aout_DummySysClose; p_aout->p_sys_close = aout_DummySysClose;
} }
#ifdef VIDEO_X11 #ifdef AUDIO_DSP
else if( !strcmp(psz_method, "dsp") ) else if( !strcmp(psz_method, "dsp") )
{ {
p_aout->p_sys_open = aout_DspSysOpen; p_aout->p_sys_open = aout_DspSysOpen;
...@@ -106,57 +105,51 @@ aout_thread_t *aout_CreateThread( int *pi_status ) ...@@ -106,57 +105,51 @@ aout_thread_t *aout_CreateThread( int *pi_status )
return( NULL ); return( NULL );
} }
//???? kludge to initialize some audio parameters - place this section somewhere
//???? else
p_aout->sys.i_format = AOUT_DEFAULT_FORMAT;
p_aout->sys.psz_device = main_GetPszVariable( AOUT_DSP_VAR, AOUT_DSP_DEFAULT );
p_aout->sys.b_stereo = main_GetIntVariable( AOUT_STEREO_VAR, AOUT_STEREO_DEFAULT );
p_aout->sys.l_rate = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT );
// ???? end of kludge
/* /*
* Initialize DSP * Initialize audio device
*/ */
if ( p_aout->p_sys_open( &p_aout->sys ) ) if ( p_aout->p_sys_open( p_aout ) )
{ {
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
if ( p_aout->p_sys_reset( &p_aout->sys ) ) if ( p_aout->p_sys_reset( p_aout ) )
{ {
p_aout->p_sys_close( &p_aout->sys ); p_aout->p_sys_close( p_aout );
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
if ( p_aout->p_sys_setformat( &p_aout->sys ) ) if ( p_aout->p_sys_setformat( p_aout ) )
{ {
p_aout->p_sys_close( &p_aout->sys ); p_aout->p_sys_close( p_aout );
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
if ( p_aout->p_sys_setchannels( &p_aout->sys ) ) if ( p_aout->p_sys_setchannels( p_aout ) )
{ {
p_aout->p_sys_close( &p_aout->sys ); p_aout->p_sys_close( p_aout );
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
if ( p_aout->p_sys_setrate( &p_aout->sys ) ) if ( p_aout->p_sys_setrate( p_aout ) )
{ {
p_aout->p_sys_close( &p_aout->sys ); p_aout->p_sys_close( p_aout );
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",
p_aout->sys.psz_device, /* this code isn't very nice since some values might be uninitialized */
p_aout->sys.i_format, /* intf_DbgMsg("aout debug: audio device (%s) opened (format=%i, channels=%i, rate=%li)\n",
p_aout->sys.b_stereo, p_aout->sys.l_rate); p_aout->psz_device,
p_aout->i_format,
p_aout->i_channels, p_aout->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 and 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 ) )
{ {
p_aout->p_sys_close( &p_aout->sys ); p_aout->p_sys_close( p_aout );
free( p_aout ); free( p_aout );
return( NULL ); return( NULL );
} }
...@@ -191,82 +184,82 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) ...@@ -191,82 +184,82 @@ 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->sys.l_rate * AOUT_BUFFER_DURATION) / 1000000 ); p_aout->l_units = (long)( ((s64)p_aout->l_rate * AOUT_BUFFER_DURATION) / 1000000 );
p_aout->l_msleep = (long)( ((s64)p_aout->l_units * 1000000) / (s64)p_aout->sys.l_rate ); p_aout->l_msleep = (long)( ((s64)p_aout->l_units * 1000000) / (s64)p_aout->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->sys.b_stereo ) switch ( p_aout->i_channels )
{ {
/* Audio output is mono */ /* Audio output is mono */
case 0: case 1:
switch ( p_aout->sys.i_format ) switch ( p_aout->i_format )
{ {
case AFMT_U8: case AOUT_FMT_U8:
l_bytes = 1 * sizeof(u8) * p_aout->l_units; l_bytes = 1 * sizeof(u8) * p_aout->l_units;
aout_thread = (void *)aout_Thread_U8_Mono; aout_thread = (void *)aout_Thread_U8_Mono;
break; break;
case AFMT_S8: case AOUT_FMT_S8:
l_bytes = 1 * sizeof(s8) * p_aout->l_units; l_bytes = 1 * sizeof(s8) * p_aout->l_units;
aout_thread = (void *)aout_Thread_S8_Mono; aout_thread = (void *)aout_Thread_S8_Mono;
break; break;
case AFMT_U16_LE: case AOUT_FMT_U16_LE:
case AFMT_U16_BE: case AOUT_FMT_U16_BE:
l_bytes = 1 * sizeof(u16) * p_aout->l_units; l_bytes = 1 * sizeof(u16) * p_aout->l_units;
aout_thread = (void *)aout_Thread_U16_Mono; aout_thread = (void *)aout_Thread_U16_Mono;
break; break;
case AFMT_S16_LE: case AOUT_FMT_S16_LE:
case AFMT_S16_BE: case AOUT_FMT_S16_BE:
l_bytes = 1 * sizeof(s16) * p_aout->l_units; l_bytes = 1 * sizeof(s16) * p_aout->l_units;
aout_thread = (void *)aout_Thread_S16_Mono; aout_thread = (void *)aout_Thread_S16_Mono;
break; break;
default: default:
intf_ErrMsg("aout error: unknown audio output format (%i)\n", intf_ErrMsg("aout error: unknown audio output format (%i)\n",
p_aout->sys.i_format); p_aout->i_format);
return( -1 ); return( -1 );
} }
break; break;
/* Audio output is stereo */ /* Audio output is stereo */
case 1: case 2:
switch ( p_aout->sys.i_format ) switch ( p_aout->i_format )
{ {
case AFMT_U8: case AOUT_FMT_U8:
l_bytes = 2 * sizeof(u8) * p_aout->l_units; l_bytes = 2 * sizeof(u8) * p_aout->l_units;
aout_thread = (void *)aout_Thread_U8_Stereo; aout_thread = (void *)aout_Thread_U8_Stereo;
break; break;
case AFMT_S8: case AOUT_FMT_S8:
l_bytes = 2 * sizeof(s8) * p_aout->l_units; l_bytes = 2 * sizeof(s8) * p_aout->l_units;
aout_thread = (void *)aout_Thread_S8_Stereo; aout_thread = (void *)aout_Thread_S8_Stereo;
break; break;
case AFMT_U16_LE: case AOUT_FMT_U16_LE:
case AFMT_U16_BE: case AOUT_FMT_U16_BE:
l_bytes = 2 * sizeof(u16) * p_aout->l_units; l_bytes = 2 * sizeof(u16) * p_aout->l_units;
aout_thread = (void *)aout_Thread_U16_Stereo; aout_thread = (void *)aout_Thread_U16_Stereo;
break; break;
case AFMT_S16_LE: case AOUT_FMT_S16_LE:
case AFMT_S16_BE: case AOUT_FMT_S16_BE:
l_bytes = 2 * sizeof(s16) * p_aout->l_units; l_bytes = 2 * sizeof(s16) * p_aout->l_units;
aout_thread = (void *)aout_Thread_S16_Stereo; aout_thread = (void *)aout_Thread_S16_Stereo;
break; break;
default: default:
intf_ErrMsg("aout error: unknown audio output format (%i)\n", intf_ErrMsg("aout error: unknown audio output format (%i)\n",
p_aout->sys.i_format); p_aout->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->sys.b_stereo + 1); p_aout->i_channels );
return( -1 ); return( -1 );
} }
...@@ -277,7 +270,7 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) ...@@ -277,7 +270,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->sys.b_stereo)) == NULL ) if ( (p_aout->s32_buffer = (s32 *)calloc(p_aout->l_units, sizeof(s32) << ( p_aout->i_channels - 1))) == 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 );
...@@ -319,8 +312,8 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status ) ...@@ -319,8 +312,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 */
p_aout->p_sys_close( &p_aout->sys ); p_aout->p_sys_close( p_aout );
intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->sys.psz_device); intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->psz_device);
free( p_aout ); free( p_aout );
} }
...@@ -356,13 +349,13 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo ) ...@@ -356,13 +349,13 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
case AOUT_INTF_STEREO_FIFO: case AOUT_INTF_STEREO_FIFO:
p_aout->fifo[i_fifo].b_die = 0; p_aout->fifo[i_fifo].b_die = 0;
p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo; p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels;
p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate; p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate;
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->sys.l_rate ); InitializeIncrement( &p_aout->fifo[i_fifo].unit_increment, p_fifo->l_rate, p_aout->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;
...@@ -370,7 +363,7 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo ) ...@@ -370,7 +363,7 @@ aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
case AOUT_ADEC_STEREO_FIFO: case AOUT_ADEC_STEREO_FIFO:
p_aout->fifo[i_fifo].b_die = 0; p_aout->fifo[i_fifo].b_die = 0;
p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo; p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels;
p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate; p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate;
p_aout->fifo[i_fifo].l_frame_size = p_fifo->l_frame_size; p_aout->fifo[i_fifo].l_frame_size = p_fifo->l_frame_size;
...@@ -487,7 +480,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m ...@@ -487,7 +480,7 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m
{ {
p_fifo->b_start_frame = 1; p_fifo->b_start_frame = 1;
p_fifo->l_next_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE; p_fifo->l_next_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE;
p_fifo->l_unit = p_fifo->l_start_frame * (p_fifo->l_frame_size >> p_fifo->b_stereo); p_fifo->l_unit = p_fifo->l_start_frame * (p_fifo->l_frame_size >> (p_fifo->i_channels - 1));
break; break;
} }
p_fifo->l_start_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE; p_fifo->l_start_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE;
...@@ -525,16 +518,16 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m ...@@ -525,16 +518,16 @@ static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, m
} }
} }
l_units = ((p_fifo->l_next_frame - p_fifo->l_start_frame) & AOUT_FIFO_SIZE) * (p_fifo->l_frame_size >> p_fifo->b_stereo); l_units = ((p_fifo->l_next_frame - p_fifo->l_start_frame) & AOUT_FIFO_SIZE) * (p_fifo->l_frame_size >> (p_fifo->i_channels - 1));
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->sys.l_rate ); InitializeIncrement( &p_fifo->unit_increment, l_rate, p_aout->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->i_channels - 1)))))
* p_aout->sys.l_rate) / l_rate) + 1; * p_aout->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 );
...@@ -585,7 +578,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -585,7 +578,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->sys.b_stereo == 1 */ while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->i_channels - 1 == 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] );
...@@ -598,7 +591,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -598,7 +591,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->sys.b_stereo == 1 */ while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->i_channels - 1 == 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] );
...@@ -616,7 +609,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -616,7 +609,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->sys.b_stereo == 1 */ while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->i_channels - 1 == 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] );
...@@ -629,7 +622,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -629,7 +622,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->sys.b_stereo */ while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->i_channels - 1 == 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] );
...@@ -659,7 +652,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -659,7 +652,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->sys.l_rate))) ) if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
{ {
break; break;
} }
...@@ -667,7 +660,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -667,7 +660,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->sys.b_stereo == 1 */ l_buffer_limit = p_aout->l_units << 1; /* p_aout->i_channels - 1 == 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++] +=
...@@ -676,10 +669,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -676,10 +669,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
(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] );
UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */ if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].i_channels - 1 == 0 */
((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) ) ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
{ {
p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */ p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].i_channels - 1 == 0 */
((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)); ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
} }
} }
...@@ -689,7 +682,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -689,7 +682,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->sys.b_stereo == 1 */ /* p_aout->i_channels - 1 == 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++] +=
...@@ -698,10 +691,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -698,10 +691,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
(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] );
UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */ if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].i_channels - 1 == 0 */
((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) ) ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
{ {
p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */ p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].i_channels - 1 == 0 */
((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)); ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
} }
} }
...@@ -736,7 +729,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -736,7 +729,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->sys.l_rate))) ) if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
{ {
break; break;
} }
...@@ -744,7 +737,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -744,7 +737,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->sys.b_stereo == 1 */ l_buffer_limit = p_aout->l_units << 1; /* p_aout->i_channels - 1 == 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++] +=
...@@ -753,10 +746,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -753,10 +746,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
(s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */ if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].i_channels - 1 == 1 */
((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) ) ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
{ {
p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */ p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].i_channels - 1 == 1 */
((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)); ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
} }
} }
...@@ -766,7 +759,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -766,7 +759,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->sys.b_stereo == 1 */ /* p_aout->i_channels - 1 == 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++] +=
...@@ -775,10 +768,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -775,10 +768,10 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
(s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */ if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].i_channels - 1 == 1 */
((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) ) ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
{ {
p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */ p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].i_channels - 1 == 1 */
((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)); ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
} }
} }
...@@ -804,7 +797,7 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -804,7 +797,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->sys.b_stereo == 1 */ l_buffer_limit = p_aout->l_units << 1; /* p_aout->i_channels - 1 == 1 */
for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ ) for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
{ {
...@@ -812,9 +805,9 @@ void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) ...@@ -812,9 +805,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;
} }
l_bytes = p_aout->p_sys_getbufinfo( &p_aout->sys ); l_bytes = p_aout->p_sys_getbufinfo( p_aout );
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->l_rate)); /* sizeof(s16) << (p_aout->i_channels - 1) == 4 */
p_aout->p_sys_playsamples( &p_aout->sys, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(s16) ); p_aout->p_sys_playsamples( p_aout, (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 );
......
...@@ -110,9 +110,9 @@ const intf_command_t control_command[] = ...@@ -110,9 +110,9 @@ const intf_command_t control_command[] =
" functions.\nIf a command name is provided as argument, displays a short "\ " functions.\nIf a command name is provided as argument, displays a short "\
"inline help about the command.\n" }, "inline help about the command.\n" },
{ "play-audio", PlayAudio, /* play-audio */ { "play-audio", PlayAudio, /* play-audio */
/* format: */ "stereo=i? rate=i? s ", /* format: */ "channels=i? rate=i? s ",
/* summary: */ "play an audio file", /* summary: */ "play an audio file",
/* usage: */ "play-audio [stereo=1/0] [rate=r] <file>", /* usage: */ "play-audio [channels=1/2] [rate=r] <file>",
/* help: */ "Load and play an audio file." }, /* help: */ "Load and play an audio file." },
{ "play-video", PlayVideo, /* play-video */ { "play-video", PlayVideo, /* play-video */
/* format: */ "s ", /* format: */ "s ",
...@@ -275,17 +275,17 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv ) ...@@ -275,17 +275,17 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
} }
/* Set default configuration */ /* Set default configuration */
fifo.b_stereo = AOUT_DEFAULT_STEREO; fifo.i_channels = 1 + AOUT_DEFAULT_STEREO;
fifo.l_rate = AOUT_DEFAULT_RATE; fifo.l_rate = AOUT_DEFAULT_RATE;
/* The stereo and rate parameters are essential ! */ /* The channels and rate parameters are essential ! */
/* Parse parameters - see command list above */ /* Parse parameters - see command list above */
for ( i_arg = 1; i_arg < i_argc; i_arg++ ) for ( i_arg = 1; i_arg < i_argc; i_arg++ )
{ {
switch( p_argv[i_arg].i_index ) switch( p_argv[i_arg].i_index )
{ {
case 0: /* stereo */ case 0: /* channels */
fifo.b_stereo = p_argv[i_arg].i_num; fifo.i_channels = p_argv[i_arg].i_num;
break; break;
case 1: /* rate */ case 1: /* rate */
fifo.l_rate = p_argv[i_arg].i_num; fifo.l_rate = p_argv[i_arg].i_num;
...@@ -297,18 +297,18 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv ) ...@@ -297,18 +297,18 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
} }
/* Setting up the type of the fifo */ /* Setting up the type of the fifo */
switch ( fifo.b_stereo ) switch ( fifo.i_channels )
{ {
case 0: case 1:
fifo.i_type = AOUT_INTF_MONO_FIFO; fifo.i_type = AOUT_INTF_MONO_FIFO;
break; break;
case 1: case 2:
fifo.i_type = AOUT_INTF_STEREO_FIFO; fifo.i_type = AOUT_INTF_STEREO_FIFO;
break; break;
default: default:
intf_IntfMsg("play-audio error: stereo must be 0 or 1"); intf_IntfMsg("play-audio error: channels must be 1 or 2");
return( INTF_OTHER_ERROR ); return( INTF_OTHER_ERROR );
} }
...@@ -322,17 +322,17 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv ) ...@@ -322,17 +322,17 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
/* Get file size to calculate number of audio units */ /* Get file size to calculate number of audio units */
fstat( i_fd, &stat_buffer ); fstat( i_fd, &stat_buffer );
fifo.l_units = ( long )( stat_buffer.st_size / (sizeof(s16) << fifo.b_stereo) ); fifo.l_units = ( long )( stat_buffer.st_size / (sizeof(s16) << (fifo.i_channels - 1)) );
/* Allocate memory, read file and close it */ /* Allocate memory, read file and close it */
if ( (fifo.buffer = malloc(sizeof(s16)*(fifo.l_units << fifo.b_stereo))) == NULL ) /* !! */ if ( (fifo.buffer = malloc(sizeof(s16)*(fifo.l_units << (fifo.i_channels - 1)))) == NULL ) /* !! */
{ {
intf_IntfMsg("play-audio error: not enough memory to read `%s'", psz_file ); intf_IntfMsg("play-audio error: not enough memory to read `%s'", psz_file );
close( i_fd ); /* close file */ close( i_fd ); /* close file */
return( INTF_OTHER_ERROR ); return( INTF_OTHER_ERROR );
} }
if ( read(i_fd, fifo.buffer, sizeof(s16)*(fifo.l_units << fifo.b_stereo)) if ( read(i_fd, fifo.buffer, sizeof(s16)*(fifo.l_units << (fifo.i_channels - 1)))
!= sizeof(s16)*(fifo.l_units << fifo.b_stereo) ) != sizeof(s16)*(fifo.l_units << (fifo.i_channels - 1)) )
{ {
intf_IntfMsg("play-audio error: can't read %s", psz_file); intf_IntfMsg("play-audio error: can't read %s", psz_file);
free( fifo.buffer ); free( fifo.buffer );
...@@ -342,7 +342,7 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv ) ...@@ -342,7 +342,7 @@ 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->sys.l_rate)/(s64)fifo.l_rate); fifo.l_units = (long)(((s64)fifo.l_units*(s64)p_main->p_aout->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 )
......
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