Commit d4243d59 authored by Sam Hocevar's avatar Sam Hocevar

  * Fixed a quite old bug in the audio output which made the sound stutter
    when wrapping around the audio output fifo.
  * Lots of simplifications in the audio output, got rid of b_stereo.
parent 0b163416
......@@ -136,7 +136,7 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \
INTERFACE := main interface intf_msg intf_playlist intf_eject
INPUT := input input_ext-dec input_ext-intf input_dec input_programs input_clock mpeg_system
VIDEO_OUTPUT := video_output video_text vout_pictures vout_subpictures
AUDIO_OUTPUT := audio_output aout_common aout_ext-dec aout_spdif
AUDIO_OUTPUT := audio_output aout_ext-dec aout_pcm aout_spdif
MISC := mtime modules configuration netutils iso_lang
C_OBJ := $(INTERFACE:%=src/interface/%.o) \
......
......@@ -2,7 +2,7 @@
* audio_output.h : audio output thread interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: audio_output.h,v 1.42 2002/02/24 20:51:09 gbazin Exp $
* $Id: audio_output.h,v 1.43 2002/02/24 22:06:50 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -54,20 +54,18 @@ typedef struct aout_increment_s
{
/* The remainder is used to keep track of the fractional part of the
* index. */
long l_remainder;
int i_r;
/*
* The increment structure is initialized with the result of an euclidean
* division :
*
* l_euclidean_numerator l_euclidean_remainder
* ----------------------- = l_euclidean_integer + -----------------------
* l_euclidean_denominator l_euclidean_denominator
* i_x i_b
* ----- = i_a + -----
* i_y i_c
*
*/
long l_euclidean_integer;
long l_euclidean_remainder;
long l_euclidean_denominator;
int i_a, i_b, i_c;
} aout_increment_t;
......@@ -76,53 +74,61 @@ typedef struct aout_increment_s
*****************************************************************************/
typedef struct aout_fifo_s
{
/* See the fifo types below */
int i_type;
/* See the fifo formats below */
int i_format;
int i_channels;
int i_rate;
int i_frame_size;
boolean_t b_die;
int i_fifo; /* Just to keep track of the fifo index */
int i_channels;
boolean_t b_stereo;
long l_rate;
vlc_mutex_t data_lock;
vlc_cond_t data_wait;
long l_frame_size;
void * buffer;
mtime_t * date;
/* The start frame is the first frame in the buffer that contains decoded
* audio data. It it also the first frame in the current timestamped frame
* area, ie the first dated frame in the decoded part of the buffer. :-p */
long l_start_frame;
int i_start_frame;
boolean_t b_start_frame;
/* The next frame is the end frame of the current timestamped frame area,
* ie the first dated frame after the start frame. */
long l_next_frame;
int i_next_frame;
boolean_t b_next_frame;
/* The end frame is the first frame, after the start frame, that doesn't
* contain decoded audio data. That's why the end frame is the first frame
* where the audio decoder can store its decoded audio frames. */
long l_end_frame;
int i_end_frame;
long l_unit;
/* Current index in p_aout->buffer */
int i_unit;
/* Max index in p_aout->buffer */
int i_unit_limit;
/* Structure used to calculate i_unit with a Bresenham algorithm */
aout_increment_t unit_increment;
/* The following variable is used to store the number of remaining audio
* units in the current timestamped frame area. */
long l_units;
int i_units;
} aout_fifo_t;
#define AOUT_FIFO_ISEMPTY( fifo ) \
( (fifo).l_end_frame == (fifo).l_start_frame )
( (fifo).i_end_frame == (fifo).i_start_frame )
#define AOUT_FIFO_ISFULL( fifo ) \
( ((((fifo).l_end_frame + 1) - (fifo).l_start_frame) & AOUT_FIFO_SIZE) == 0 )
( ((((fifo).i_end_frame + 1) - (fifo).i_start_frame) & AOUT_FIFO_SIZE) == 0 )
#define AOUT_FIFO_INC( i_index ) \
( ((i_index) + 1) & AOUT_FIFO_SIZE )
#define AOUT_EMPTY_FIFO 0
#define AOUT_ADEC_MONO_FIFO 1
#define AOUT_ADEC_STEREO_FIFO 2
#define AOUT_ADEC_SPDIF_FIFO 3
/* List of known fifo formats */
#define AOUT_FIFO_NONE 0
#define AOUT_FIFO_PCM 1
#define AOUT_FIFO_SPDIF 2
/*****************************************************************************
* aout_thread_t : audio output thread descriptor
......@@ -140,7 +146,7 @@ typedef struct aout_thread_s
struct module_s * p_module;
int ( *pf_open ) ( p_aout_thread_t );
int ( *pf_setformat ) ( p_aout_thread_t );
long ( *pf_getbufinfo ) ( p_aout_thread_t, long );
int ( *pf_getbufinfo ) ( p_aout_thread_t, int );
void ( *pf_play ) ( p_aout_thread_t, byte_t *, int );
void ( *pf_close ) ( p_aout_thread_t );
......@@ -151,8 +157,8 @@ typedef struct aout_thread_s
/* The size of the audio output buffer is kept in audio units, as this is
* the only unit that is common with every audio decoder and audio fifo */
long l_units;
long l_msleep;
int i_units;
int i_msleep;
/* date is the moment where the first audio unit of the output buffer
* will be played */
......@@ -161,15 +167,14 @@ typedef struct aout_thread_s
/* The current volume */
int i_volume;
int i_savedvolume;
/* Format of the audio output samples */
/* Format of the audio output samples, number of channels, and
* rate and gain (in Hz) of the audio output sound */
int i_format;
/* Number of channels */
int i_channels;
/* Mono or Stereo sound */
boolean_t b_stereo;
/* Rate and gain of the audio output sound (in Hz) */
long l_rate;
long l_gain;
int i_rate;
/* Latency of the audio output plugin, in bytes */
int i_latency;
/* there might be some useful private structure, such as audio_buf_info
......@@ -207,11 +212,10 @@ typedef struct aout_thread_s
void aout_InitBank ( void );
void aout_EndBank ( void );
aout_thread_t * aout_CreateThread ( int *pi_status, int i_channels,
long l_rate );
aout_thread_t * aout_CreateThread ( int *, int, int );
void aout_DestroyThread ( aout_thread_t *, int * );
aout_fifo_t * aout_CreateFifo ( int, int, long, long, long, void * );
aout_fifo_t * aout_CreateFifo ( int, int, int, int, void * );
void aout_DestroyFifo ( aout_fifo_t *p_fifo );
void aout_FreeFifo ( aout_fifo_t *p_fifo );
#else
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: common.h,v 1.77 2002/02/24 21:36:20 jobi Exp $
* $Id: common.h,v 1.78 2002/02/24 22:06:50 sam Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -542,8 +542,7 @@ typedef struct module_symbols_s
struct pgrm_descriptor_s *,
mtime_t );
struct aout_fifo_s * ( * aout_CreateFifo )
( int, int, long, long, long, void * );
struct aout_fifo_s * ( * aout_CreateFifo ) ( int, int, int, int, void * );
void ( * aout_DestroyFifo ) ( struct aout_fifo_s * );
struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, u32, int );
......
/* include/defs.h.in. Generated automatically from configure.in by autoheader. */
/* include/defs.h.in. Generated automatically from configure.in by autoheader 2.13. */
/* Define if using alloca.c. */
#undef C_ALLOCA
......
......@@ -2,7 +2,7 @@
* modules.h : Module management functions.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.h,v 1.42 2002/02/24 20:51:09 gbazin Exp $
* $Id: modules.h,v 1.43 2002/02/24 22:06:50 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -212,7 +212,7 @@ typedef struct function_list_s
{
int ( * pf_open ) ( struct aout_thread_s * );
int ( * pf_setformat ) ( struct aout_thread_s * );
long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
int ( * pf_getbufinfo ) ( struct aout_thread_s *, int );
void ( * pf_play ) ( struct aout_thread_s *, byte_t *, int );
void ( * pf_close ) ( struct aout_thread_s * );
} aout;
......
......@@ -4,7 +4,7 @@
* (http://liba52.sf.net/).
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: a52.c,v 1.4 2002/02/24 20:51:09 gbazin Exp $
* $Id: a52.c,v 1.5 2002/02/24 22:06:50 sam Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -213,7 +213,7 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec )
int i;
if( ( p_a52_adec->p_aout_fifo != NULL ) &&
( p_a52_adec->p_aout_fifo->l_rate != p_a52_adec->sample_rate ) )
( p_a52_adec->p_aout_fifo->i_rate != p_a52_adec->sample_rate ) )
{
/* Make sure the output thread leaves the NextFrame() function */
vlc_mutex_lock (&(p_a52_adec->p_aout_fifo->data_lock));
......@@ -227,9 +227,9 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec )
/* Creating the audio output fifo if not created yet */
if (p_a52_adec->p_aout_fifo == NULL )
{
p_a52_adec->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO,
p_a52_adec->p_aout_fifo = aout_CreateFifo( AOUT_FIFO_PCM,
p_a52_adec->i_channels,
p_a52_adec->sample_rate, 0,
p_a52_adec->sample_rate,
AC3DEC_FRAME_SIZE * p_a52_adec->i_channels,
NULL );
......@@ -242,20 +242,20 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec )
/* Set the Presentation Time Stamp */
CurrentPTS( &p_a52_adec->bit_stream,
&p_a52_adec->p_aout_fifo->date[
p_a52_adec->p_aout_fifo->l_end_frame],
p_a52_adec->p_aout_fifo->i_end_frame],
NULL );
if( !p_a52_adec->p_aout_fifo->date[
p_a52_adec->p_aout_fifo->l_end_frame] )
p_a52_adec->p_aout_fifo->i_end_frame] )
{
p_a52_adec->p_aout_fifo->date[
p_a52_adec->p_aout_fifo->l_end_frame] = LAST_MDATE;
p_a52_adec->p_aout_fifo->i_end_frame] = LAST_MDATE;
}
p_buffer = ((byte_t *)p_a52_adec->p_aout_fifo->buffer) +
( p_a52_adec->p_aout_fifo->l_end_frame * AC3DEC_FRAME_SIZE *
( p_a52_adec->p_aout_fifo->i_end_frame * AC3DEC_FRAME_SIZE *
p_a52_adec->i_channels * sizeof(s16) );
/* FIXME */
......@@ -280,8 +280,8 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec )
vlc_mutex_lock( &p_a52_adec->p_aout_fifo->data_lock );
p_a52_adec->p_aout_fifo->l_end_frame =
(p_a52_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
p_a52_adec->p_aout_fifo->i_end_frame =
(p_a52_adec->p_aout_fifo->i_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_cond_signal (&p_a52_adec->p_aout_fifo->data_wait);
vlc_mutex_unlock (&p_a52_adec->p_aout_fifo->data_lock);
......
......@@ -2,7 +2,7 @@
* ac3_adec.c: ac3 decoder module main file
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ac3_adec.c,v 1.21 2002/02/24 20:51:09 gbazin Exp $
* $Id: ac3_adec.c,v 1.22 2002/02/24 22:06:50 sam Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
*
......@@ -279,7 +279,7 @@ static int decoder_Run ( decoder_config_t * p_config )
}
if( ( p_ac3thread->p_aout_fifo != NULL ) &&
( p_ac3thread->p_aout_fifo->l_rate != sync_info.sample_rate ) )
( p_ac3thread->p_aout_fifo->i_rate != sync_info.sample_rate ) )
{
/* Make sure the output thread leaves the NextFrame() function */
vlc_mutex_lock (&(p_ac3thread->p_aout_fifo->data_lock));
......@@ -292,8 +292,8 @@ static int decoder_Run ( decoder_config_t * p_config )
/* Creating the audio output fifo if not created yet */
if (p_ac3thread->p_aout_fifo == NULL ) {
p_ac3thread->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO,
2, sync_info.sample_rate, 0, AC3DEC_FRAME_SIZE, NULL );
p_ac3thread->p_aout_fifo = aout_CreateFifo( AOUT_FIFO_PCM, 2,
sync_info.sample_rate, AC3DEC_FRAME_SIZE, NULL );
if ( p_ac3thread->p_aout_fifo == NULL )
{
free( IMDCT->w_1 );
......@@ -326,17 +326,17 @@ static int decoder_Run ( decoder_config_t * p_config )
}
CurrentPTS( &p_ac3thread->ac3_decoder->bit_stream,
&p_ac3thread->p_aout_fifo->date[p_ac3thread->p_aout_fifo->l_end_frame],
&p_ac3thread->p_aout_fifo->date[p_ac3thread->p_aout_fifo->i_end_frame],
NULL );
if( !p_ac3thread->p_aout_fifo->date[p_ac3thread->p_aout_fifo->l_end_frame] )
if( !p_ac3thread->p_aout_fifo->date[p_ac3thread->p_aout_fifo->i_end_frame] )
{
p_ac3thread->p_aout_fifo->date[
p_ac3thread->p_aout_fifo->l_end_frame] =
p_ac3thread->p_aout_fifo->i_end_frame] =
LAST_MDATE;
}
buffer = ((s16 *)p_ac3thread->p_aout_fifo->buffer) +
(p_ac3thread->p_aout_fifo->l_end_frame * AC3DEC_FRAME_SIZE);
(p_ac3thread->p_aout_fifo->i_end_frame * AC3DEC_FRAME_SIZE);
if (ac3_decode_frame (p_ac3thread->ac3_decoder, buffer))
{
......@@ -345,8 +345,8 @@ static int decoder_Run ( decoder_config_t * p_config )
}
vlc_mutex_lock (&p_ac3thread->p_aout_fifo->data_lock);
p_ac3thread->p_aout_fifo->l_end_frame =
(p_ac3thread->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE;
p_ac3thread->p_aout_fifo->i_end_frame =
(p_ac3thread->p_aout_fifo->i_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_cond_signal (&p_ac3thread->p_aout_fifo->data_wait);
vlc_mutex_unlock (&p_ac3thread->p_aout_fifo->data_lock);
......
......@@ -2,7 +2,7 @@
* ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: ac3_spdif.c,v 1.15 2002/02/24 20:51:09 gbazin Exp $
* $Id: ac3_spdif.c,v 1.16 2002/02/24 22:06:50 sam Exp $
*
* Authors: Stphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi>
......@@ -157,19 +157,19 @@ static int decoder_Run( decoder_config_t * p_config )
/* if we're late here the output won't have to play the frame */
if( i_current_pts > mdate() )
{
p_spdif->p_aout_fifo->date[p_spdif->p_aout_fifo->l_end_frame] =
p_spdif->p_aout_fifo->date[p_spdif->p_aout_fifo->i_end_frame] =
i_current_pts;
/* Write in the first free packet of aout fifo */
p_spdif->p_iec = ((u8*)(p_spdif->p_aout_fifo->buffer) +
(p_spdif->p_aout_fifo->l_end_frame * SPDIF_FRAME_SIZE ));
(p_spdif->p_aout_fifo->i_end_frame * SPDIF_FRAME_SIZE ));
/* Build burst to be sent to hardware decoder */
ac3_iec958_build_burst( p_spdif );
vlc_mutex_lock (&p_spdif->p_aout_fifo->data_lock);
p_spdif->p_aout_fifo->l_end_frame =
(p_spdif->p_aout_fifo->l_end_frame + 1 ) & AOUT_FIFO_SIZE;
p_spdif->p_aout_fifo->i_end_frame =
(p_spdif->p_aout_fifo->i_end_frame + 1 ) & AOUT_FIFO_SIZE;
vlc_mutex_unlock (&p_spdif->p_aout_fifo->data_lock);
}
......@@ -265,9 +265,9 @@ static int InitThread( ac3_spdif_thread_t * p_spdif )
}
/* Creating the audio output fifo */
p_spdif->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_SPDIF_FIFO, 1,
p_spdif->p_aout_fifo = aout_CreateFifo( AOUT_FIFO_SPDIF, 1,
p_spdif->ac3_info.i_sample_rate,
0, SPDIF_FRAME_SIZE, NULL );
SPDIF_FRAME_SIZE, NULL );
if( p_spdif->p_aout_fifo == NULL )
{
......
......@@ -2,7 +2,7 @@
* aout_alsa.c : Alsa functions library
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: aout_alsa.c,v 1.27 2002/02/19 00:50:19 sam Exp $
* $Id: aout_alsa.c,v 1.28 2002/02/24 22:06:50 sam Exp $
*
* Authors: Henri Fallon <henri@videolan.org> - Original Author
* Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API
......@@ -162,7 +162,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
}
i_rv = snd_pcm_hw_params_set_rate_near( p_aout->p_sys->p_alsa_handle, p_hw,
p_aout->l_rate, 0 );
p_aout->i_rate, 0 );
if( i_rv < 0 )
{
intf_ErrMsg( "aout error: unable to set sample rate" );
......@@ -253,7 +253,7 @@ static void aout_HandleXrun(aout_thread_t *p_aout)
* of data to play, it switches to the "underrun" status. It has to
* be flushed and re-prepared
*****************************************************************************/
static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
static long aout_GetBufInfo( aout_thread_t *p_aout, int i_buffer_limit )
{
snd_pcm_status_t *p_status;
int i_alsa_get_status_returns;
......
......@@ -53,7 +53,7 @@ typedef struct aout_sys_s
*****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( aout_thread_t *p_aout );
static long aout_GetBufInfo ( aout_thread_t *p_aout, long l_buffer_info );
static int aout_GetBufInfo ( aout_thread_t *p_aout, int i_buffer_info );
static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout );
......@@ -96,7 +96,7 @@ static int aout_Open( aout_thread_t *p_aout )
}
p_aout->p_sys->stream =
arts_play_stream( p_aout->l_rate, 16, p_aout->i_channels, "vlc" );
arts_play_stream( p_aout->i_rate, 16, p_aout->i_channels, "vlc" );
return( 0 );
}
......@@ -118,10 +118,10 @@ static int aout_SetFormat( aout_thread_t *p_aout )
/*****************************************************************************
* aout_GetBufInfo: buffer status query
*****************************************************************************/
static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
static int aout_GetBufInfo( aout_thread_t *p_aout, int i_buffer_limit )
{
/* arbitrary value that should be changed */
return( l_buffer_limit );
return( i_buffer_limit );
}
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* aout_beos.cpp: BeOS audio output
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: aout_beos.cpp,v 1.22 2002/02/24 20:51:09 gbazin Exp $
* $Id: aout_beos.cpp,v 1.23 2002/02/24 22:06:50 sam Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -55,8 +55,8 @@ typedef struct aout_sys_s
BPushGameSound * p_sound;
gs_audio_format * p_format;
void * p_buffer;
long i_buffer_size;
long i_buffer_pos;
int i_buffer_size;
int i_buffer_pos;
} aout_sys_t;
......@@ -68,7 +68,7 @@ extern "C"
*****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( aout_thread_t *p_aout );
static long aout_GetBufInfo ( aout_thread_t *p_aout, long l_buffer_info );
static int aout_GetBufInfo ( aout_thread_t *p_aout, int i_buffer_info );
static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout );
......@@ -155,10 +155,10 @@ static int aout_SetFormat( aout_thread_t *p_aout )
/*****************************************************************************
* aout_GetBufInfo: buffer status query
*****************************************************************************/
static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
static int aout_GetBufInfo( aout_thread_t *p_aout, int i_buffer_limit )
{
/* Each value is 4 bytes long (stereo signed 16 bits) */
long i_hard_pos = 4 * p_aout->p_sys->p_sound->CurrentPosition();
int i_hard_pos = 4 * p_aout->p_sys->p_sound->CurrentPosition();
i_hard_pos = p_aout->p_sys->i_buffer_pos - i_hard_pos;
if( i_hard_pos < 0 )
......@@ -176,7 +176,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
*****************************************************************************/
static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
{
long i_newbuf_pos;
int i_newbuf_pos;
if( (i_newbuf_pos = p_aout->p_sys->i_buffer_pos + i_size)
> p_aout->p_sys->i_buffer_size )
......
......@@ -2,7 +2,7 @@
* aout_directx.c: Windows DirectX audio output method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: aout_directx.c,v 1.19 2002/02/24 20:51:09 gbazin Exp $
* $Id: aout_directx.c,v 1.20 2002/02/24 22:06:50 sam Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -68,12 +68,12 @@ typedef struct aout_sys_s
HINSTANCE hdsound_dll; /* handle of the opened dsound dll */
long l_buffer_size; /* secondary sound buffer size */
long l_write_position; /* next write position for the buffer */
int i_buffer_size; /* secondary sound buffer size */
int i_write_position; /* next write position for the buffer */
volatile boolean_t b_buffer_underflown; /* buffer underflow detection */
volatile long l_data_played_from_beginning; /* for underflow detection */
volatile long l_data_written_from_beginning; /* for underflow detection */
volatile int i_data_played_from_beginning; /* for underflow detection */
volatile int i_data_written_from_beginning; /* for underflow detection */
vlc_mutex_t buffer_lock; /* audio buffer lock */
......@@ -90,7 +90,7 @@ typedef struct aout_sys_s
*****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( aout_thread_t *p_aout );
static long aout_GetBufInfo ( aout_thread_t *p_aout, long l_buffer_info );
static int aout_GetBufInfo ( aout_thread_t *p_aout, int i_buffer_info );
static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout );
......@@ -141,8 +141,8 @@ static int aout_Open( aout_thread_t *p_aout )
p_aout->p_sys->p_dsbuffer = NULL;
p_aout->p_sys->p_dsnotify = NULL;
p_aout->p_sys->b_notification_thread_die = 0;
p_aout->p_sys->l_data_written_from_beginning = 0;
p_aout->p_sys->l_data_played_from_beginning = 0;
p_aout->p_sys->i_data_written_from_beginning = 0;
p_aout->p_sys->i_data_played_from_beginning = 0;
vlc_mutex_init( &p_aout->p_sys->buffer_lock );
......@@ -205,7 +205,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
{
HRESULT dsresult;
WAVEFORMATEX *p_waveformat;
unsigned long i_size_struct;
unsigned int i_size_struct;
intf_WarnMsg( 3, "aout: DirectX aout_SetFormat ");
......@@ -227,8 +227,8 @@ static int aout_SetFormat( aout_thread_t *p_aout )
{
/* Here we'll change the format */
p_waveformat->nChannels = 2;
p_waveformat->nSamplesPerSec = (p_aout->l_rate < 44100) ? 44100
: p_aout->l_rate;
p_waveformat->nSamplesPerSec = (p_aout->i_rate < 44100) ? 44100
: p_aout->i_rate;
p_waveformat->wBitsPerSample = 16;
p_waveformat->nBlockAlign = p_waveformat->wBitsPerSample / 8 *
p_waveformat->nChannels;
......@@ -271,34 +271,34 @@ static int aout_SetFormat( aout_thread_t *p_aout )
* returns the number of bytes in the audio buffer that have not yet been
* sent to the sound device.
*****************************************************************************/
static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
static int aout_GetBufInfo( aout_thread_t *p_aout, int i_buffer_limit )
{
long l_play_position, l_notused, l_result;
int i_play_position, i_notused, i_result;
HRESULT dsresult;
if( p_aout->p_sys->b_buffer_underflown )
{
intf_WarnMsg( 3, "aout: DirectX aout_GetBufInfo underflow");
return( l_buffer_limit );
return( i_buffer_limit );
}
dsresult = IDirectSoundBuffer_GetCurrentPosition(p_aout->p_sys->p_dsbuffer,
&l_play_position, &l_notused);
&i_play_position, &i_notused);
if( dsresult != DS_OK )
{
intf_WarnMsg(3,"aout: DirectX aout_GetBufInfo cannot get current pos");
return( l_buffer_limit );
return( i_buffer_limit );
}
l_result = (p_aout->p_sys->l_write_position >= l_play_position) ?
(p_aout->p_sys->l_write_position - l_play_position)
: (p_aout->p_sys->l_buffer_size - l_play_position
+ p_aout->p_sys->l_write_position);
i_result = (p_aout->p_sys->i_write_position >= i_play_position) ?
(p_aout->p_sys->i_write_position - i_play_position)
: (p_aout->p_sys->i_buffer_size - i_play_position
+ p_aout->p_sys->i_write_position);
#if 0
intf_WarnMsg( 3, "aout: DirectX aout_GetBufInfo: %li", l_result);
intf_WarnMsg( 3, "aout: DirectX aout_GetBufInfo: %i", i_result);
#endif
return l_result;
return i_result;
}
/*****************************************************************************
......@@ -310,7 +310,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
{
VOID *p_write_position, *p_start_buffer;
long l_bytes1, l_bytes2, l_play_position;
int i_bytes1, i_bytes2, i_play_position;
HRESULT dsresult;
/* protect buffer access (because of DirectSoundThread) */
......@@ -322,30 +322,30 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
* as soon as possible. This is why we query the play position */
dsresult = IDirectSoundBuffer_GetCurrentPosition(
p_aout->p_sys->p_dsbuffer,
&l_play_position,
&p_aout->p_sys->l_write_position );
&i_play_position,
&p_aout->p_sys->i_write_position );
if( dsresult != DS_OK )
{
intf_WarnMsg( 3, "aout: aout_Play can'get buffer position");
p_aout->p_sys->l_write_position = 0;
p_aout->p_sys->i_write_position = 0;
}
intf_WarnMsg( 3, "aout: aout_Play underflow");
/* reinitialise the underflow detection counters */
p_aout->p_sys->b_buffer_underflown = 0;
p_aout->p_sys->l_data_written_from_beginning = 0;
p_aout->p_sys->i_data_written_from_beginning = 0;