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 \ ...@@ -136,7 +136,7 @@ PLUGINS_TARGETS := ac3_adec/ac3_adec \
INTERFACE := main interface intf_msg intf_playlist intf_eject 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 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 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 MISC := mtime modules configuration netutils iso_lang
C_OBJ := $(INTERFACE:%=src/interface/%.o) \ C_OBJ := $(INTERFACE:%=src/interface/%.o) \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* audio_output.h : audio output thread interface * audio_output.h : audio output thread interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * 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> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr> * Cyril Deguet <asmax@via.ecp.fr>
...@@ -54,20 +54,18 @@ typedef struct aout_increment_s ...@@ -54,20 +54,18 @@ typedef struct aout_increment_s
{ {
/* The remainder is used to keep track of the fractional part of the /* The remainder is used to keep track of the fractional part of the
* index. */ * index. */
long l_remainder; int i_r;
/* /*
* The increment structure is initialized with the result of an euclidean * The increment structure is initialized with the result of an euclidean
* division : * division :
* *
* l_euclidean_numerator l_euclidean_remainder * i_x i_b
* ----------------------- = l_euclidean_integer + ----------------------- * ----- = i_a + -----
* l_euclidean_denominator l_euclidean_denominator * i_y i_c
* *
*/ */
long l_euclidean_integer; int i_a, i_b, i_c;
long l_euclidean_remainder;
long l_euclidean_denominator;
} aout_increment_t; } aout_increment_t;
...@@ -76,53 +74,61 @@ typedef struct aout_increment_s ...@@ -76,53 +74,61 @@ typedef struct aout_increment_s
*****************************************************************************/ *****************************************************************************/
typedef struct aout_fifo_s typedef struct aout_fifo_s
{ {
/* See the fifo types below */ /* See the fifo formats below */
int i_type; int i_format;
int i_channels;
int i_rate;
int i_frame_size;
boolean_t b_die; boolean_t b_die;
int i_fifo; /* Just to keep track of the fifo index */ 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_mutex_t data_lock;
vlc_cond_t data_wait; vlc_cond_t data_wait;
long l_frame_size;
void * buffer; void * buffer;
mtime_t * date; mtime_t * date;
/* The start frame is the first frame in the buffer that contains decoded /* 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 * 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 */ * 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; boolean_t b_start_frame;
/* The next frame is the end frame of the current timestamped frame area, /* The next frame is the end frame of the current timestamped frame area,
* ie the first dated frame after the start frame. */ * ie the first dated frame after the start frame. */
long l_next_frame; int i_next_frame;
boolean_t b_next_frame; boolean_t b_next_frame;
/* The end frame is the first frame, after the start frame, that doesn't /* 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 * contain decoded audio data. That's why the end frame is the first frame
* where the audio decoder can store its decoded audio frames. */ * 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; aout_increment_t unit_increment;
/* The following variable is used to store the number of remaining audio /* The following variable is used to store the number of remaining audio
* units in the current timestamped frame area. */ * units in the current timestamped frame area. */
long l_units; int i_units;
} aout_fifo_t; } aout_fifo_t;
#define AOUT_FIFO_ISEMPTY( fifo ) \ #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 ) \ #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 /* List of known fifo formats */
#define AOUT_ADEC_MONO_FIFO 1 #define AOUT_FIFO_NONE 0
#define AOUT_ADEC_STEREO_FIFO 2 #define AOUT_FIFO_PCM 1
#define AOUT_ADEC_SPDIF_FIFO 3 #define AOUT_FIFO_SPDIF 2
/***************************************************************************** /*****************************************************************************
* aout_thread_t : audio output thread descriptor * aout_thread_t : audio output thread descriptor
...@@ -140,7 +146,7 @@ typedef struct aout_thread_s ...@@ -140,7 +146,7 @@ typedef struct aout_thread_s
struct module_s * p_module; struct module_s * p_module;
int ( *pf_open ) ( p_aout_thread_t ); int ( *pf_open ) ( p_aout_thread_t );
int ( *pf_setformat ) ( 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_play ) ( p_aout_thread_t, byte_t *, int );
void ( *pf_close ) ( p_aout_thread_t ); void ( *pf_close ) ( p_aout_thread_t );
...@@ -151,8 +157,8 @@ typedef struct aout_thread_s ...@@ -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 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 */ * the only unit that is common with every audio decoder and audio fifo */
long l_units; int i_units;
long l_msleep; int i_msleep;
/* date is the moment where the first audio unit of the output buffer /* date is the moment where the first audio unit of the output buffer
* will be played */ * will be played */
...@@ -161,15 +167,14 @@ typedef struct aout_thread_s ...@@ -161,15 +167,14 @@ typedef struct aout_thread_s
/* The current volume */ /* The current volume */
int i_volume; int i_volume;
int i_savedvolume; 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; int i_format;
/* Number of channels */
int i_channels; int i_channels;
/* Mono or Stereo sound */ int i_rate;
boolean_t b_stereo;
/* Rate and gain of the audio output sound (in Hz) */ /* Latency of the audio output plugin, in bytes */
long l_rate;
long l_gain;
int i_latency; int i_latency;
/* there might be some useful private structure, such as audio_buf_info /* there might be some useful private structure, such as audio_buf_info
...@@ -207,11 +212,10 @@ typedef struct aout_thread_s ...@@ -207,11 +212,10 @@ typedef struct aout_thread_s
void aout_InitBank ( void ); void aout_InitBank ( void );
void aout_EndBank ( void ); void aout_EndBank ( void );
aout_thread_t * aout_CreateThread ( int *pi_status, int i_channels, aout_thread_t * aout_CreateThread ( int *, int, int );
long l_rate );
void aout_DestroyThread ( aout_thread_t *, 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_DestroyFifo ( aout_fifo_t *p_fifo );
void aout_FreeFifo ( aout_fifo_t *p_fifo ); void aout_FreeFifo ( aout_fifo_t *p_fifo );
#else #else
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions * Collection of useful common types and macros definitions
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * 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> * Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr> * Vincent Seguin <seguin@via.ecp.fr>
...@@ -542,8 +542,7 @@ typedef struct module_symbols_s ...@@ -542,8 +542,7 @@ typedef struct module_symbols_s
struct pgrm_descriptor_s *, struct pgrm_descriptor_s *,
mtime_t ); mtime_t );
struct aout_fifo_s * ( * aout_CreateFifo ) struct aout_fifo_s * ( * aout_CreateFifo ) ( int, int, int, int, void * );
( int, int, long, long, long, void * );
void ( * aout_DestroyFifo ) ( struct aout_fifo_s * ); void ( * aout_DestroyFifo ) ( struct aout_fifo_s * );
struct vout_thread_s * (* vout_CreateThread) ( int *, int, int, u32, int ); 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. */ /* Define if using alloca.c. */
#undef C_ALLOCA #undef C_ALLOCA
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* modules.h : Module management functions. * modules.h : Module management functions.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -212,7 +212,7 @@ typedef struct function_list_s ...@@ -212,7 +212,7 @@ typedef struct function_list_s
{ {
int ( * pf_open ) ( struct aout_thread_s * ); int ( * pf_open ) ( struct aout_thread_s * );
int ( * pf_setformat ) ( 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_play ) ( struct aout_thread_s *, byte_t *, int );
void ( * pf_close ) ( struct aout_thread_s * ); void ( * pf_close ) ( struct aout_thread_s * );
} aout; } aout;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* (http://liba52.sf.net/). * (http://liba52.sf.net/).
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -213,7 +213,7 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec ) ...@@ -213,7 +213,7 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec )
int i; int i;
if( ( p_a52_adec->p_aout_fifo != NULL ) && 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 */ /* Make sure the output thread leaves the NextFrame() function */
vlc_mutex_lock (&(p_a52_adec->p_aout_fifo->data_lock)); 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 ) ...@@ -227,9 +227,9 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec )
/* Creating the audio output fifo if not created yet */ /* Creating the audio output fifo if not created yet */
if (p_a52_adec->p_aout_fifo == NULL ) 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->i_channels,
p_a52_adec->sample_rate, 0, p_a52_adec->sample_rate,
AC3DEC_FRAME_SIZE * p_a52_adec->i_channels, AC3DEC_FRAME_SIZE * p_a52_adec->i_channels,
NULL ); NULL );
...@@ -242,20 +242,20 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec ) ...@@ -242,20 +242,20 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec )
/* Set the Presentation Time Stamp */ /* Set the Presentation Time Stamp */
CurrentPTS( &p_a52_adec->bit_stream, CurrentPTS( &p_a52_adec->bit_stream,
&p_a52_adec->p_aout_fifo->date[ &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 ); NULL );
if( !p_a52_adec->p_aout_fifo->date[ 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->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_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) ); p_a52_adec->i_channels * sizeof(s16) );
/* FIXME */ /* FIXME */
...@@ -280,8 +280,8 @@ static int DecodeFrame( a52_adec_thread_t * p_a52_adec ) ...@@ -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 ); 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->i_end_frame =
(p_a52_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; (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_cond_signal (&p_a52_adec->p_aout_fifo->data_wait);
vlc_mutex_unlock (&p_a52_adec->p_aout_fifo->data_lock); vlc_mutex_unlock (&p_a52_adec->p_aout_fifo->data_lock);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_adec.c: ac3 decoder module main file * ac3_adec.c: ac3 decoder module main file
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * 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> * Authors: Michel Lespinasse <walken@zoy.org>
* *
...@@ -279,7 +279,7 @@ static int decoder_Run ( decoder_config_t * p_config ) ...@@ -279,7 +279,7 @@ static int decoder_Run ( decoder_config_t * p_config )
} }
if( ( p_ac3thread->p_aout_fifo != NULL ) && 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 */ /* Make sure the output thread leaves the NextFrame() function */
vlc_mutex_lock (&(p_ac3thread->p_aout_fifo->data_lock)); vlc_mutex_lock (&(p_ac3thread->p_aout_fifo->data_lock));
...@@ -292,8 +292,8 @@ static int decoder_Run ( decoder_config_t * p_config ) ...@@ -292,8 +292,8 @@ static int decoder_Run ( decoder_config_t * p_config )
/* Creating the audio output fifo if not created yet */ /* Creating the audio output fifo if not created yet */
if (p_ac3thread->p_aout_fifo == NULL ) { if (p_ac3thread->p_aout_fifo == NULL ) {
p_ac3thread->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO, p_ac3thread->p_aout_fifo = aout_CreateFifo( AOUT_FIFO_PCM, 2,
2, sync_info.sample_rate, 0, AC3DEC_FRAME_SIZE, NULL ); sync_info.sample_rate, AC3DEC_FRAME_SIZE, NULL );
if ( p_ac3thread->p_aout_fifo == NULL ) if ( p_ac3thread->p_aout_fifo == NULL )
{ {
free( IMDCT->w_1 ); free( IMDCT->w_1 );
...@@ -326,17 +326,17 @@ static int decoder_Run ( decoder_config_t * p_config ) ...@@ -326,17 +326,17 @@ static int decoder_Run ( decoder_config_t * p_config )
} }
CurrentPTS( &p_ac3thread->ac3_decoder->bit_stream, 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 ); 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->date[
p_ac3thread->p_aout_fifo->l_end_frame] = p_ac3thread->p_aout_fifo->i_end_frame] =
LAST_MDATE; LAST_MDATE;
} }
buffer = ((s16 *)p_ac3thread->p_aout_fifo->buffer) + 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)) if (ac3_decode_frame (p_ac3thread->ac3_decoder, buffer))
{ {
...@@ -345,8 +345,8 @@ static int decoder_Run ( decoder_config_t * p_config ) ...@@ -345,8 +345,8 @@ static int decoder_Run ( decoder_config_t * p_config )
} }
vlc_mutex_lock (&p_ac3thread->p_aout_fifo->data_lock); vlc_mutex_lock (&p_ac3thread->p_aout_fifo->data_lock);
p_ac3thread->p_aout_fifo->l_end_frame = p_ac3thread->p_aout_fifo->i_end_frame =
(p_ac3thread->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; (p_ac3thread->p_aout_fifo->i_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_cond_signal (&p_ac3thread->p_aout_fifo->data_wait); vlc_cond_signal (&p_ac3thread->p_aout_fifo->data_wait);
vlc_mutex_unlock (&p_ac3thread->p_aout_fifo->data_lock); vlc_mutex_unlock (&p_ac3thread->p_aout_fifo->data_lock);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard * ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Stphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi> * Juha Yrjola <jyrjola@cc.hut.fi>
...@@ -157,19 +157,19 @@ static int decoder_Run( decoder_config_t * p_config ) ...@@ -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 we're late here the output won't have to play the frame */
if( i_current_pts > mdate() ) 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; i_current_pts;
/* Write in the first free packet of aout fifo */ /* Write in the first free packet of aout fifo */
p_spdif->p_iec = ((u8*)(p_spdif->p_aout_fifo->buffer) + 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 */ /* Build burst to be sent to hardware decoder */
ac3_iec958_build_burst( p_spdif ); ac3_iec958_build_burst( p_spdif );
vlc_mutex_lock (&p_spdif->p_aout_fifo->data_lock); vlc_mutex_lock (&p_spdif->p_aout_fifo->data_lock);
p_spdif->p_aout_fifo->l_end_frame = p_spdif->p_aout_fifo->i_end_frame =
(p_spdif->p_aout_fifo->l_end_frame + 1 ) & AOUT_FIFO_SIZE; (p_spdif->p_aout_fifo->i_end_frame + 1 ) & AOUT_FIFO_SIZE;
vlc_mutex_unlock (&p_spdif->p_aout_fifo->data_lock); vlc_mutex_unlock (&p_spdif->p_aout_fifo->data_lock);
} }
...@@ -265,9 +265,9 @@ static int InitThread( ac3_spdif_thread_t * p_spdif ) ...@@ -265,9 +265,9 @@ static int InitThread( ac3_spdif_thread_t * p_spdif )
} }
/* Creating the audio output fifo */ /* 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, p_spdif->ac3_info.i_sample_rate,
0, SPDIF_FRAME_SIZE, NULL ); SPDIF_FRAME_SIZE, NULL );
if( p_spdif->p_aout_fifo == NULL ) if( p_spdif->p_aout_fifo == NULL )
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_alsa.c : Alsa functions library * aout_alsa.c : Alsa functions library
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * 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 * Authors: Henri Fallon <henri@videolan.org> - Original Author
* Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API * Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API
...@@ -162,7 +162,7 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -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, 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 ) if( i_rv < 0 )
{ {
intf_ErrMsg( "aout error: unable to set sample rate" ); intf_ErrMsg( "aout error: unable to set sample rate" );
...@@ -253,7 +253,7 @@ static void aout_HandleXrun(aout_thread_t *p_aout) ...@@ -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 * of data to play, it switches to the "underrun" status. It has to
* be flushed and re-prepared * 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; snd_pcm_status_t *p_status;
int i_alsa_get_status_returns; int i_alsa_get_status_returns;
......
...@@ -53,7 +53,7 @@ typedef struct aout_sys_s ...@@ -53,7 +53,7 @@ typedef struct aout_sys_s
*****************************************************************************/ *****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout ); static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( 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, static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
...@@ -96,7 +96,7 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -96,7 +96,7 @@ static int aout_Open( aout_thread_t *p_aout )
} }
p_aout->p_sys->stream = 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 ); return( 0 );
} }
...@@ -118,10 +118,10 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -118,10 +118,10 @@ static int aout_SetFormat( aout_thread_t *p_aout )
/***************************************************************************** /*****************************************************************************
* aout_GetBufInfo: buffer status query * 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 */ /* arbitrary value that should be changed */
return( l_buffer_limit ); return( i_buffer_limit );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_beos.cpp: BeOS audio output * aout_beos.cpp: BeOS audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * 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> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -55,8 +55,8 @@ typedef struct aout_sys_s ...@@ -55,8 +55,8 @@ typedef struct aout_sys_s
BPushGameSound * p_sound; BPushGameSound * p_sound;
gs_audio_format * p_format; gs_audio_format * p_format;
void * p_buffer; void * p_buffer;
long i_buffer_size; int i_buffer_size;
long i_buffer_pos; int i_buffer_pos;
} aout_sys_t; } aout_sys_t;
...@@ -68,7 +68,7 @@ extern "C" ...@@ -68,7 +68,7 @@ extern "C"
*****************************************************************************/ *****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout ); static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( 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, static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
...@@ -155,10 +155,10 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -155,10 +155,10 @@ static int aout_SetFormat( aout_thread_t *p_aout )
/***************************************************************************** /*****************************************************************************
* aout_GetBufInfo: buffer status query * 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) */ /* 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; i_hard_pos = p_aout->p_sys->i_buffer_pos - i_hard_pos;
if( i_hard_pos < 0 ) if( i_hard_pos < 0 )
...@@ -176,7 +176,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit ) ...@@ -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 ) 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) if( (i_newbuf_pos = p_aout->p_sys->i_buffer_pos + i_size)
> p_aout->p_sys->i_buffer_size ) > p_aout->p_sys->i_buffer_size )
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_dsp.c : dsp functions library * aout_dsp.c : dsp functions library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: aout_dsp.c,v 1.22 2002/02/24 20:51:09 gbazin Exp $ * $Id: aout_dsp.c,v 1.23 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -75,7 +75,7 @@ typedef struct aout_sys_s ...@@ -75,7 +75,7 @@ typedef struct aout_sys_s
*****************************************************************************/ *****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout ); static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( 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, static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
...@@ -142,8 +142,8 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -142,8 +142,8 @@ static int aout_Open( aout_thread_t *p_aout )
static int aout_SetFormat( aout_thread_t *p_aout ) static int aout_SetFormat( aout_thread_t *p_aout )
{ {
int i_format; int i_format;
long l_rate; int i_rate;
boolean_t b_stereo = p_aout->b_stereo; boolean_t b_stereo;
/* Reset the DSP device */ /* Reset the DSP device */
if( ioctl( p_aout->p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 ) if( ioctl( p_aout->p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 )
...@@ -170,6 +170,8 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -170,6 +170,8 @@ static int aout_SetFormat( aout_thread_t *p_aout )
} }
/* Set the number of channels */ /* Set the number of channels */
b_stereo = ( p_aout->i_channels >= 2 );
if( ioctl( p_aout->p_sys->i_fd, SNDCTL_DSP_STEREO, &b_stereo ) < 0 ) if( ioctl( p_aout->p_sys->i_fd, SNDCTL_DSP_STEREO, &b_stereo ) < 0 )
{ {
intf_ErrMsg( "aout error: can't set number of audio channels (%i)", intf_ErrMsg( "aout error: can't set number of audio channels (%i)",
...@@ -177,28 +179,27 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -177,28 +179,27 @@ static int aout_SetFormat( aout_thread_t *p_aout )
return( -1 ); return( -1 );
} }
if( b_stereo != p_aout->b_stereo ) if( (1 + b_stereo) != p_aout->i_channels )
{ {
intf_WarnMsg( 2, "aout warning: number of audio channels not supported" intf_WarnMsg( 2, "aout warning: %i audio channels not supported",
" (%i)", p_aout->i_channels ); p_aout->i_channels );
p_aout->b_stereo = b_stereo;
p_aout->i_channels = 1 + b_stereo; p_aout->i_channels = 1 + b_stereo;
} }
/* Set the output rate */ /* Set the output rate */
l_rate = p_aout->l_rate; i_rate = p_aout->i_rate;
if( ioctl( p_aout->p_sys->i_fd, SNDCTL_DSP_SPEED, &l_rate ) < 0 ) if( ioctl( p_aout->p_sys->i_fd, SNDCTL_DSP_SPEED, &l_rate ) < 0 )
{ {
intf_ErrMsg( "aout error: can't set audio output rate (%li)", intf_ErrMsg( "aout error: can't set audio output rate (%i)",
p_aout->l_rate ); p_aout->i_rate );
return( -1 ); return( -1 );
} }
if( l_rate != p_aout->l_rate ) if( i_rate != p_aout->i_rate )
{ {
intf_WarnMsg( 1, "aout warning: audio output rate not supported (%li)", intf_WarnMsg( 1, "aout warning: audio output rate not supported (%li)",
p_aout->l_rate ); p_aout->i_rate );
p_aout->l_rate = l_rate; p_aout->i_rate = i_rate;
} }
return( 0 ); return( 0 );
...@@ -208,14 +209,13 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -208,14 +209,13 @@ static int aout_SetFormat( aout_thread_t *p_aout )
* aout_GetBufInfo: buffer status query * aout_GetBufInfo: buffer status query
***************************************************************************** *****************************************************************************
* This function fills in the audio_buf_info structure : * This function fills in the audio_buf_info structure :
* - int fragments : number of available fragments (partially usend ones not * - returns : number of available fragments (not partially used ones)
* counted)
* - int fragstotal : total number of fragments allocated * - int fragstotal : total number of fragments allocated
* - int fragsize : size of a fragment in bytes * - int fragsize : size of a fragment in bytes
* - int bytes : available space in bytes (includes partially used fragments) * - int bytes : available space in bytes (includes partially used fragments)
* Note! 'bytes' could be more than fragments*fragsize * Note! 'bytes' could be more than fragments*fragsize
*****************************************************************************/ *****************************************************************************/
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 )
{ {
ioctl( p_aout->p_sys->i_fd, SNDCTL_DSP_GETOSPACE, ioctl( p_aout->p_sys->i_fd, SNDCTL_DSP_GETOSPACE,
&p_aout->p_sys->audio_buf ); &p_aout->p_sys->audio_buf );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_dummy.c : dummy audio output plugin * aout_dummy.c : dummy audio output plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: aout_dummy.c,v 1.19 2002/02/15 13:32:53 sam Exp $ * $Id: aout_dummy.c,v 1.20 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -48,7 +48,7 @@ typedef struct aout_sys_s ...@@ -48,7 +48,7 @@ typedef struct aout_sys_s
*****************************************************************************/ *****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout ); static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( 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, static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
...@@ -85,9 +85,9 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -85,9 +85,9 @@ static int aout_SetFormat( aout_thread_t *p_aout )
/***************************************************************************** /*****************************************************************************
* aout_GetBufInfo: returns available bytes in buffer * aout_GetBufInfo: returns available bytes in buffer
*****************************************************************************/ *****************************************************************************/
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 )
{ {
return( sizeof(s16) * l_buffer_limit + 1 ); /* value big enough to sleep */ return( sizeof(s16) * i_buffer_limit + 1 ); /* value big enough to sleep */
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_esd.c : Esound functions library * aout_esd.c : Esound functions library
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2001 VideoLAN * Copyright (C) 2000-2001 VideoLAN
* $Id: aout_esd.c,v 1.20 2002/02/24 20:51:09 gbazin Exp $ * $Id: aout_esd.c,v 1.21 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -61,7 +61,7 @@ typedef struct aout_sys_s ...@@ -61,7 +61,7 @@ typedef struct aout_sys_s
*****************************************************************************/ *****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout ); static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( 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, static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
...@@ -98,7 +98,7 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -98,7 +98,7 @@ static int aout_Open( aout_thread_t *p_aout )
} }
/* Initialize some variables */ /* Initialize some variables */
p_aout->l_rate = esd_audio_rate; /* We use actual esd rate value, not p_aout->i_rate = esd_audio_rate; /* We use actual esd rate value, not
* initial value */ * initial value */
i_bits = ESD_BITS16; i_bits = ESD_BITS16;
...@@ -119,11 +119,11 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -119,11 +119,11 @@ static int aout_Open( aout_thread_t *p_aout )
* and try to open /dev/dsp if there's no EsounD */ * and try to open /dev/dsp if there's no EsounD */
if ( (p_aout->p_sys->i_fd if ( (p_aout->p_sys->i_fd
= esd_play_stream_fallback(p_aout->p_sys->esd_format, = esd_play_stream_fallback(p_aout->p_sys->esd_format,
p_aout->l_rate, NULL, "vlc")) < 0 ) p_aout->i_rate, NULL, "vlc")) < 0 )
{ {
intf_ErrMsg( "aout error: can't open esound socket" intf_ErrMsg( "aout error: can't open esound socket"
" (format 0x%08x at %ld Hz)", " (format 0x%08x at %ld Hz)",
p_aout->p_sys->esd_format, p_aout->l_rate ); p_aout->p_sys->esd_format, p_aout->i_rate );
return( -1 ); return( -1 );
} }
...@@ -148,10 +148,10 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -148,10 +148,10 @@ static int aout_SetFormat( aout_thread_t *p_aout )
/***************************************************************************** /*****************************************************************************
* aout_GetBufInfo: buffer status query * 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 */ /* arbitrary value that should be changed */
return( l_buffer_limit ); return( i_buffer_limit );
} }
/***************************************************************************** /*****************************************************************************
...@@ -167,22 +167,22 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size ) ...@@ -167,22 +167,22 @@ static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
{ {
if (p_aout->p_sys->esd_format & ESD_BITS16) if (p_aout->p_sys->esd_format & ESD_BITS16)
{ {
i_amount = (44100 * (ESD_BUF_SIZE + 64)) / p_aout->l_rate; i_amount = (44100 * (ESD_BUF_SIZE + 64)) / p_aout->i_rate;
} }
else else
{ {
i_amount = (44100 * (ESD_BUF_SIZE + 128)) / p_aout->l_rate; i_amount = (44100 * (ESD_BUF_SIZE + 128)) / p_aout->i_rate;
} }
} }
else else
{ {
if (p_aout->p_sys->esd_format & ESD_BITS16) if (p_aout->p_sys->esd_format & ESD_BITS16)
{ {
i_amount = (2 * 44100 * (ESD_BUF_SIZE + 128)) / p_aout->l_rate; i_amount = (2 * 44100 * (ESD_BUF_SIZE + 128)) / p_aout->i_rate;
} }
else else
{ {
i_amount = (2 * 44100 * (ESD_BUF_SIZE + 256)) / p_aout->l_rate; i_amount = (2 * 44100 * (ESD_BUF_SIZE + 256)) / p_aout->i_rate;
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* lpcm_decoder_thread.c: lpcm decoder thread * lpcm_decoder_thread.c: lpcm decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: lpcm_adec.c,v 1.12 2002/02/19 00:50:19 sam Exp $ * $Id: lpcm_adec.c,v 1.13 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Henri Fallon <henri@videolan.org> * Henri Fallon <henri@videolan.org>
...@@ -145,8 +145,8 @@ static int InitThread (lpcmdec_thread_t * p_lpcmdec) ...@@ -145,8 +145,8 @@ static int InitThread (lpcmdec_thread_t * p_lpcmdec)
NULL, NULL); NULL, NULL);
/* Creating the audio output fifo */ /* Creating the audio output fifo */
p_lpcmdec->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_STEREO_FIFO, 2, 48000, p_lpcmdec->p_aout_fifo = aout_CreateFifo( AOUT_FIFO_PCM, 2, 48000,
0, LPCMDEC_FRAME_SIZE/2, NULL ); LPCMDEC_FRAME_SIZE/2, NULL );
if ( p_lpcmdec->p_aout_fifo == NULL ) if ( p_lpcmdec->p_aout_fifo == NULL )
{ {
return( -1 ); return( -1 );
...@@ -164,16 +164,16 @@ void DecodeFrame( lpcmdec_thread_t * p_lpcmdec ) ...@@ -164,16 +164,16 @@ void DecodeFrame( lpcmdec_thread_t * p_lpcmdec )
byte_t byte1, byte2; byte_t byte1, byte2;
CurrentPTS( &p_lpcmdec->bit_stream, CurrentPTS( &p_lpcmdec->bit_stream,
&p_lpcmdec->p_aout_fifo->date[p_lpcmdec->p_aout_fifo->l_end_frame], &p_lpcmdec->p_aout_fifo->date[p_lpcmdec->p_aout_fifo->i_end_frame],
NULL ); NULL );
if( !p_lpcmdec->p_aout_fifo->date[p_lpcmdec->p_aout_fifo->l_end_frame] ) if( !p_lpcmdec->p_aout_fifo->date[p_lpcmdec->p_aout_fifo->i_end_frame] )
{ {
p_lpcmdec->p_aout_fifo->date[p_lpcmdec->p_aout_fifo->l_end_frame] = p_lpcmdec->p_aout_fifo->date[p_lpcmdec->p_aout_fifo->i_end_frame] =
LAST_MDATE; LAST_MDATE;
} }
buffer = ((byte_t *)p_lpcmdec->p_aout_fifo->buffer) + buffer = ((byte_t *)p_lpcmdec->p_aout_fifo->buffer) +
(p_lpcmdec->p_aout_fifo->l_end_frame * LPCMDEC_FRAME_SIZE); (p_lpcmdec->p_aout_fifo->i_end_frame * LPCMDEC_FRAME_SIZE);
RemoveBits32(&p_lpcmdec->bit_stream); RemoveBits32(&p_lpcmdec->bit_stream);
byte1 = GetBits(&p_lpcmdec->bit_stream, 8) ; byte1 = GetBits(&p_lpcmdec->bit_stream, 8) ;
...@@ -199,8 +199,8 @@ void DecodeFrame( lpcmdec_thread_t * p_lpcmdec ) ...@@ -199,8 +199,8 @@ void DecodeFrame( lpcmdec_thread_t * p_lpcmdec )
} }
vlc_mutex_lock (&p_lpcmdec->p_aout_fifo->data_lock); vlc_mutex_lock (&p_lpcmdec->p_aout_fifo->data_lock);
p_lpcmdec->p_aout_fifo->l_end_frame = p_lpcmdec->p_aout_fifo->i_end_frame =
(p_lpcmdec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; (p_lpcmdec->p_aout_fifo->i_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_cond_signal (&p_lpcmdec->p_aout_fifo->data_wait); vlc_cond_signal (&p_lpcmdec->p_aout_fifo->data_wait);
vlc_mutex_unlock (&p_lpcmdec->p_aout_fifo->data_lock); vlc_mutex_unlock (&p_lpcmdec->p_aout_fifo->data_lock);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_darwin.c : Darwin audio output plugin * aout_darwin.c : Darwin audio output plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: aout_macosx.c,v 1.13 2002/02/19 00:50:19 sam Exp $ * $Id: aout_macosx.c,v 1.14 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Colin Delacroix <colin@zoy.org> * Authors: Colin Delacroix <colin@zoy.org>
* *
...@@ -78,7 +78,7 @@ typedef struct aout_sys_s ...@@ -78,7 +78,7 @@ typedef struct aout_sys_s
*****************************************************************************/ *****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout ); static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( 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, static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
...@@ -178,7 +178,7 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -178,7 +178,7 @@ static int aout_Open( aout_thread_t *p_aout )
* not be forced to compute the same value twice * not be forced to compute the same value twice
*/ */
p_aout->p_sys->ui_deviceBufferSize = p_aout->p_sys->ui_deviceBufferSize =
2 * 2 * sizeof(s16) * ((s64)p_aout->l_rate * AOUT_BUFFER_DURATION) / 1000000; 2 * 2 * sizeof(s16) * ((s64)p_aout->i_rate * AOUT_BUFFER_DURATION) / 1000000;
/* Allocate memory for audio */ /* Allocate memory for audio */
p_aout->p_sys->p_Data = NewPtrClear( p_aout->p_sys->ui_deviceBufferSize ); p_aout->p_sys->p_Data = NewPtrClear( p_aout->p_sys->ui_deviceBufferSize );
...@@ -280,7 +280,7 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -280,7 +280,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
// format.mFormatFlags |= kLinearPCMFormatFlagIsFloat; // format.mFormatFlags |= kLinearPCMFormatFlagIsFloat;
// format.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger; // format.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
format.mSampleRate = p_aout->l_rate; format.mSampleRate = p_aout->i_rate;
format.mChannelsPerFrame = p_aout->i_channels; format.mChannelsPerFrame = p_aout->i_channels;
err = AudioDeviceSetProperty( p_aout->p_sys->device, 0, 0, false, err = AudioDeviceSetProperty( p_aout->p_sys->device, 0, 0, false,
...@@ -312,7 +312,7 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -312,7 +312,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
/***************************************************************************** /*****************************************************************************
* aout_GetBufInfo: returns available bytes in buffer * aout_GetBufInfo: returns available bytes in buffer
*****************************************************************************/ *****************************************************************************/
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 )
{ {
return( 0 ); // Send data as soon as possible return( 0 ); // Send data as soon as possible
......
...@@ -155,7 +155,7 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream) ...@@ -155,7 +155,7 @@ enum mad_flow libmad_input(void *data, struct mad_stream *p_libmad_stream)
* *
* intf_ErrMsg( "mad_adec: libmad_header samplerate %d", p_libmad_header->samplerate); * intf_ErrMsg( "mad_adec: libmad_header samplerate %d", p_libmad_header->samplerate);
* *
* p_mad_adec->p_aout_fifo->l_rate = p_libmad_header->samplerate; * p_mad_adec->p_aout_fifo->i_rate = p_libmad_header->samplerate;
* mad_timer_add(&p_mad_adec->libmad_timer,p_libmad_header->duration); * mad_timer_add(&p_mad_adec->libmad_timer,p_libmad_header->duration);
* *
* return MAD_FLOW_CONTINUE; * return MAD_FLOW_CONTINUE;
...@@ -300,10 +300,9 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header ...@@ -300,10 +300,9 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
if (p_mad_adec->p_aout_fifo==NULL) if (p_mad_adec->p_aout_fifo==NULL)
{ {
p_mad_adec->p_aout_fifo = aout_CreateFifo( p_mad_adec->p_aout_fifo = aout_CreateFifo(
AOUT_ADEC_STEREO_FIFO, /* fifo type */ AOUT_FIFO_PCM, /* fifo type */
p_libmad_pcm->channels, /* nr. of channels */ p_libmad_pcm->channels, /* nr. of channels */
p_libmad_pcm->samplerate, /* frame rate in Hz ?*/ p_libmad_pcm->samplerate, /* frame rate in Hz ?*/
0, /* units */
ADEC_FRAME_SIZE, /* frame size */ ADEC_FRAME_SIZE, /* frame size */
NULL ); /* buffer */ NULL ); /* buffer */
...@@ -315,27 +314,27 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header ...@@ -315,27 +314,27 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
intf_ErrMsg("mad_adec debug: in libmad_output aout fifo created"); intf_ErrMsg("mad_adec debug: in libmad_output aout fifo created");
} }
if (p_mad_adec->p_aout_fifo->l_rate != p_libmad_pcm->samplerate) if (p_mad_adec->p_aout_fifo->i_rate != p_libmad_pcm->samplerate)
{ {
intf_ErrMsg( "mad_adec: libmad_output samplerate is changing from [%d] Hz to [%d] Hz, sample size [%d], error_code [%0x]", intf_ErrMsg( "mad_adec: libmad_output samplerate is changing from [%d] Hz to [%d] Hz, sample size [%d], error_code [%0x]",
p_mad_adec->p_aout_fifo->l_rate, p_libmad_pcm->samplerate, p_mad_adec->p_aout_fifo->i_rate, p_libmad_pcm->samplerate,
p_libmad_pcm->length, p_mad_adec->libmad_decoder->sync->stream.error); p_libmad_pcm->length, p_mad_adec->libmad_decoder->sync->stream.error);
p_mad_adec->p_aout_fifo->l_rate = p_libmad_pcm->samplerate; p_mad_adec->p_aout_fifo->i_rate = p_libmad_pcm->samplerate;
} }
if( p_mad_adec->i_current_pts ) if( p_mad_adec->i_current_pts )
{ {
p_mad_adec->p_aout_fifo->date[p_mad_adec->p_aout_fifo->l_end_frame] p_mad_adec->p_aout_fifo->date[p_mad_adec->p_aout_fifo->i_end_frame]
= p_mad_adec->i_current_pts; = p_mad_adec->i_current_pts;
} }
else else
{ {
p_mad_adec->p_aout_fifo->date[p_mad_adec->p_aout_fifo->l_end_frame] p_mad_adec->p_aout_fifo->date[p_mad_adec->p_aout_fifo->i_end_frame]
= LAST_MDATE; = LAST_MDATE;
} }
mad_timer_add(&p_mad_adec->libmad_timer,p_libmad_header->duration); mad_timer_add(&p_mad_adec->libmad_timer,p_libmad_header->duration);
buffer = ((byte_t *)p_mad_adec->p_aout_fifo->buffer) + (p_mad_adec->p_aout_fifo->l_end_frame * MAD_OUTPUT_SIZE); buffer = ((byte_t *)p_mad_adec->p_aout_fifo->buffer) + (p_mad_adec->p_aout_fifo->i_end_frame * MAD_OUTPUT_SIZE);
while (nsamples--) while (nsamples--)
{ {
...@@ -384,7 +383,7 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header ...@@ -384,7 +383,7 @@ enum mad_flow libmad_output(void *data, struct mad_header const *p_libmad_header
} }
vlc_mutex_lock (&p_mad_adec->p_aout_fifo->data_lock); vlc_mutex_lock (&p_mad_adec->p_aout_fifo->data_lock);
p_mad_adec->p_aout_fifo->l_end_frame = (p_mad_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; p_mad_adec->p_aout_fifo->i_end_frame = (p_mad_adec->p_aout_fifo->i_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_cond_signal (&p_mad_adec->p_aout_fifo->data_wait); vlc_cond_signal (&p_mad_adec->p_aout_fifo->data_wait);
vlc_mutex_unlock (&p_mad_adec->p_aout_fifo->data_lock); vlc_mutex_unlock (&p_mad_adec->p_aout_fifo->data_lock);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* adec_layer1.c: MPEG Layer I audio decoder * adec_layer1.c: MPEG Layer I audio decoder
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: adec_layer1.c,v 1.5 2001/12/30 07:09:55 sam Exp $ * $Id: adec_layer1.c,v 1.6 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr> * Michel Lespinasse <walken@via.ecp.fr>
...@@ -155,8 +155,6 @@ int adec_layer1_mono( adec_thread_t * p_adec, s16 * buffer ) ...@@ -155,8 +155,6 @@ int adec_layer1_mono( adec_thread_t * p_adec, s16 * buffer )
for ( s = 0 ; s < 12; s++) for ( s = 0 ; s < 12; s++)
{ {
s16 * XXX_buf;
for (i_sb = 0; i_sb < 32; i_sb++) for (i_sb = 0; i_sb < 32; i_sb++)
{ {
if (!allocation[i_sb]) if (!allocation[i_sb])
...@@ -174,9 +172,8 @@ int adec_layer1_mono( adec_thread_t * p_adec, s16 * buffer ) ...@@ -174,9 +172,8 @@ int adec_layer1_mono( adec_thread_t * p_adec, s16 * buffer )
} }
} }
DCT32 (sample, &p_adec->bank_0); DCT32( &p_adec->bank_0, sample );
XXX_buf = buffer; PCM (&p_adec->bank_0, buffer, 1);
PCM (&p_adec->bank_0, &XXX_buf, 1);
buffer += 32; buffer += 32;
} }
...@@ -291,8 +288,6 @@ int adec_layer1_stereo( adec_thread_t * p_adec, s16 * buffer ) ...@@ -291,8 +288,6 @@ int adec_layer1_stereo( adec_thread_t * p_adec, s16 * buffer )
for (s = 0; s < 12; s++) for (s = 0; s < 12; s++)
{ {
s16 * XXX_buf;
for (i_sb = 0; i_sb < bound; i_sb++) for (i_sb = 0; i_sb < bound; i_sb++)
{ {
if (!allocation_0[i_sb]) if (!allocation_0[i_sb])
...@@ -343,12 +338,10 @@ int adec_layer1_stereo( adec_thread_t * p_adec, s16 * buffer ) ...@@ -343,12 +338,10 @@ int adec_layer1_stereo( adec_thread_t * p_adec, s16 * buffer )
} }
} }
DCT32 (sample_0, &p_adec->bank_0); DCT32( &p_adec->bank_0, sample_0 );
XXX_buf = buffer; PCM (&p_adec->bank_0, buffer, 2);
PCM (&p_adec->bank_0, &XXX_buf, 2); DCT32( &p_adec->bank_1, sample_1 );
DCT32 (sample_1, &p_adec->bank_1); PCM (&p_adec->bank_1, buffer + 1, 2);
XXX_buf = buffer+1;
PCM (&p_adec->bank_1, &XXX_buf, 2);
buffer += 64; buffer += 64;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* adec_layer2.c: MPEG Layer II audio decoder * adec_layer2.c: MPEG Layer II audio decoder
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: adec_layer2.c,v 1.5 2001/12/30 07:09:55 sam Exp $ * $Id: adec_layer2.c,v 1.6 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr> * Michel Lespinasse <walken@via.ecp.fr>
...@@ -372,8 +372,6 @@ int adec_layer2_mono( adec_thread_t * p_adec, s16 * buffer ) ...@@ -372,8 +372,6 @@ int adec_layer2_mono( adec_thread_t * p_adec, s16 * buffer )
{ {
for (gr1 = 0; gr1 < 4; gr1++) for (gr1 = 0; gr1 < 4; gr1++)
{ {
s16 * XXX_buf;
for (sb = 0; sb < sblimit; sb++) for (sb = 0; sb < sblimit; sb++)
{ {
int code; int code;
...@@ -437,14 +435,12 @@ int adec_layer2_mono( adec_thread_t * p_adec, s16 * buffer ) ...@@ -437,14 +435,12 @@ int adec_layer2_mono( adec_thread_t * p_adec, s16 * buffer )
for (s = 0; s < 3; s++) for (s = 0; s < 3; s++)
{ {
DCT32 (sample[s], &p_adec->bank_0); DCT32( &p_adec->bank_0, sample[s] );
XXX_buf = buffer; PCM( &p_adec->bank_0, buffer, 2 );
PCM (&p_adec->bank_0, &XXX_buf, 2);
/* FIXME: one shouldn't have to do it twice ! */ /* FIXME: one shouldn't have to do it twice ! */
DCT32 (sample[s], &p_adec->bank_1); DCT32( &p_adec->bank_1, sample[s] );
XXX_buf = buffer+1; PCM( &p_adec->bank_1, buffer + 1, 2 );
PCM (&p_adec->bank_1, &XXX_buf, 2);
buffer += 64; buffer += 64;
} }
...@@ -798,8 +794,6 @@ int adec_layer2_stereo( adec_thread_t * p_adec, s16 * buffer ) ...@@ -798,8 +794,6 @@ int adec_layer2_stereo( adec_thread_t * p_adec, s16 * buffer )
{ {
for (gr1 = 0; gr1 < 4; gr1++) for (gr1 = 0; gr1 < 4; gr1++)
{ {
s16 * XXX_buf;
for (sb = 0; sb < bound; sb++) for (sb = 0; sb < bound; sb++)
{ {
int code; int code;
...@@ -983,13 +977,11 @@ int adec_layer2_stereo( adec_thread_t * p_adec, s16 * buffer ) ...@@ -983,13 +977,11 @@ int adec_layer2_stereo( adec_thread_t * p_adec, s16 * buffer )
for (s = 0; s < 3; s++) for (s = 0; s < 3; s++)
{ {
DCT32 (sample_0[s], &p_adec->bank_0); DCT32( &p_adec->bank_0, sample_0[s] );
XXX_buf = buffer; PCM( &p_adec->bank_0, buffer, 2 );
PCM (&p_adec->bank_0, &XXX_buf, 2);
DCT32 (sample_1[s], &p_adec->bank_1); DCT32( &p_adec->bank_1, sample_1[s] );
XXX_buf = buffer+1; PCM( &p_adec->bank_1, buffer + 1, 2 );
PCM (&p_adec->bank_1, &XXX_buf, 2);
buffer += 64; buffer += 64;
} }
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* adec_math.h : PCM and DCT * adec_math.h : PCM and DCT
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: adec_math.h,v 1.1 2001/11/13 12:09:18 henri Exp $ * $Id: adec_math.h,v 1.2 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* *
...@@ -24,6 +24,6 @@ ...@@ -24,6 +24,6 @@
/***************************************************************************** /*****************************************************************************
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
void DCT32(float *x, adec_bank_t *b); void DCT32 ( adec_bank_t *, float * );
void PCM(adec_bank_t *b, s16 **pcm, int jump); void PCM ( adec_bank_t *, s16 *, int );
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpeg_adec.c: MPEG audio decoder thread * mpeg_adec.c: MPEG audio decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: mpeg_adec.c,v 1.20 2002/02/24 20:51:10 gbazin Exp $ * $Id: mpeg_adec.c,v 1.21 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr> * Michel Lespinasse <walken@via.ecp.fr>
...@@ -157,7 +157,7 @@ static int decoder_Run ( decoder_config_t * p_config ) ...@@ -157,7 +157,7 @@ static int decoder_Run ( decoder_config_t * p_config )
*****************************************************************************/ *****************************************************************************/
static void DecodeThread( adec_thread_t * p_adec ) static void DecodeThread( adec_thread_t * p_adec )
{ {
s16 * buffer; s16 *p_buffer;
adec_sync_info_t sync_info; adec_sync_info_t sync_info;
if( ! adec_SyncFrame (p_adec, &sync_info) ) if( ! adec_SyncFrame (p_adec, &sync_info) )
...@@ -168,31 +168,26 @@ static void DecodeThread( adec_thread_t * p_adec ) ...@@ -168,31 +168,26 @@ static void DecodeThread( adec_thread_t * p_adec )
/* Create the output fifo if it doesn't exist yet */ /* Create the output fifo if it doesn't exist yet */
if( p_adec->p_aout_fifo == NULL ) if( p_adec->p_aout_fifo == NULL )
{ {
int fifo_type; int i_channels;
int channels;
if( p_main->b_stereo ) if( p_main->b_stereo )
{ {
intf_WarnMsg( 4, "adec info: setting stereo output" ); intf_WarnMsg( 4, "adec info: setting stereo output" );
fifo_type = AOUT_ADEC_STEREO_FIFO; i_channels = 2;
channels = 2;
} }
else if( sync_info.b_stereo ) else if( sync_info.b_stereo )
{ {
fifo_type = AOUT_ADEC_STEREO_FIFO; i_channels = 2;
channels = 2;
} }
else else
{ {
fifo_type = AOUT_ADEC_MONO_FIFO; i_channels = 1;
channels = 1;
} }
p_adec->p_aout_fifo = aout_CreateFifo( fifo_type, channels, p_adec->p_aout_fifo = aout_CreateFifo( AOUT_FIFO_PCM, i_channels,
sync_info.sample_rate, 0, ADEC_FRAME_SIZE, NULL ); sync_info.sample_rate, ADEC_FRAME_SIZE, NULL );
if( p_adec->p_aout_fifo == NULL) if( p_adec->p_aout_fifo == NULL)
{ {
intf_ErrMsg( "adec error: failed to create Audio Output " intf_ErrMsg( "adec error: failed to create aout fifo" );
"Fifo." );
p_adec->p_fifo->b_error = 1; p_adec->p_fifo->b_error = 1;
return; return;
} }
...@@ -200,19 +195,19 @@ static void DecodeThread( adec_thread_t * p_adec ) ...@@ -200,19 +195,19 @@ static void DecodeThread( adec_thread_t * p_adec )
p_adec->i_sync = 1; p_adec->i_sync = 1;
buffer = ((s16 *)p_adec->p_aout_fifo->buffer) p_buffer = ((s16 *)p_adec->p_aout_fifo->buffer)
+ (p_adec->p_aout_fifo->l_end_frame * ADEC_FRAME_SIZE); + (p_adec->p_aout_fifo->i_end_frame * ADEC_FRAME_SIZE);
CurrentPTS( &p_adec->bit_stream, CurrentPTS( &p_adec->bit_stream,
&p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame], &p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->i_end_frame],
NULL ); NULL );
if( !p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] ) if( !p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->i_end_frame] )
{ {
p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->i_end_frame] =
LAST_MDATE; LAST_MDATE;
} }
if( adec_DecodeFrame (p_adec, buffer) ) if( adec_DecodeFrame (p_adec, p_buffer) )
{ {
/* Ouch, failed decoding... We'll have to resync */ /* Ouch, failed decoding... We'll have to resync */
p_adec->i_sync = 0; p_adec->i_sync = 0;
...@@ -220,8 +215,8 @@ static void DecodeThread( adec_thread_t * p_adec ) ...@@ -220,8 +215,8 @@ static void DecodeThread( adec_thread_t * p_adec )
else else
{ {
vlc_mutex_lock (&p_adec->p_aout_fifo->data_lock); vlc_mutex_lock (&p_adec->p_aout_fifo->data_lock);
p_adec->p_aout_fifo->l_end_frame = p_adec->p_aout_fifo->i_end_frame =
(p_adec->p_aout_fifo->l_end_frame + 1) & AOUT_FIFO_SIZE; (p_adec->p_aout_fifo->i_end_frame + 1) & AOUT_FIFO_SIZE;
vlc_cond_signal (&p_adec->p_aout_fifo->data_wait); vlc_cond_signal (&p_adec->p_aout_fifo->data_wait);
vlc_mutex_unlock (&p_adec->p_aout_fifo->data_lock); vlc_mutex_unlock (&p_adec->p_aout_fifo->data_lock);
} }
......
...@@ -47,7 +47,7 @@ typedef struct aout_sys_s ...@@ -47,7 +47,7 @@ typedef struct aout_sys_s
*****************************************************************************/ *****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout ); static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( 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, static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
...@@ -144,7 +144,7 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -144,7 +144,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
pp.buf.block.frags_min = 1; pp.buf.block.frags_min = 1;
pp.format.interleave = 1; pp.format.interleave = 1;
pp.format.rate = p_aout->l_rate; pp.format.rate = p_aout->i_rate;
pp.format.voices = p_aout->i_channels; pp.format.voices = p_aout->i_channels;
switch( p_aout->i_format ) switch( p_aout->i_format )
...@@ -161,7 +161,7 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -161,7 +161,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
} }
pp.buf.block.frag_size = pp.buf.block.frag_size =
(((s64)p_aout->l_rate * AOUT_BUFFER_DURATION) / 1000000) * (((s64)p_aout->i_rate * AOUT_BUFFER_DURATION) / 1000000) *
p_aout->i_channels * i_bytes_per_sample; p_aout->i_channels * i_bytes_per_sample;
/* set parameters */ /* set parameters */
...@@ -193,7 +193,7 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -193,7 +193,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
* of data to play, it switches to the "underrun" status. It has to * of data to play, it switches to the "underrun" status. It has to
* be flushed and re-prepared * be flushed and re-prepared
*****************************************************************************/ *****************************************************************************/
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 )
{ {
int i_ret; int i_ret;
snd_pcm_channel_status_t status; snd_pcm_channel_status_t status;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_sdl.c : audio sdl functions library * aout_sdl.c : audio sdl functions library
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: aout_sdl.c,v 1.26 2002/02/24 20:51:10 gbazin Exp $ * $Id: aout_sdl.c,v 1.27 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -63,7 +63,7 @@ typedef struct aout_sys_s ...@@ -63,7 +63,7 @@ typedef struct aout_sys_s
*****************************************************************************/ *****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout ); static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( 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, static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
...@@ -92,7 +92,6 @@ void _M( aout_getfunctions )( function_list_t * p_function_list ) ...@@ -92,7 +92,6 @@ void _M( aout_getfunctions )( function_list_t * p_function_list )
static int aout_Open( aout_thread_t *p_aout ) static int aout_Open( aout_thread_t *p_aout )
{ {
SDL_AudioSpec desired; SDL_AudioSpec desired;
int i_channels = p_aout->b_stereo ? 2 : 1;
if( SDL_WasInit( SDL_INIT_AUDIO ) != 0 ) if( SDL_WasInit( SDL_INIT_AUDIO ) != 0 )
{ {
...@@ -130,12 +129,12 @@ static int aout_Open( aout_thread_t *p_aout ) ...@@ -130,12 +129,12 @@ static int aout_Open( aout_thread_t *p_aout )
p_aout->p_sys->audio_buf = malloc( OVERFLOWLIMIT ); p_aout->p_sys->audio_buf = malloc( OVERFLOWLIMIT );
/* Initialize some variables */ /* Initialize some variables */
desired.freq = p_aout->l_rate;
/* TODO: write conversion beetween AOUT_FORMAT_DEFAULT /* TODO: write conversion beetween AOUT_FORMAT_DEFAULT
* AND AUDIO* from SDL. */ * AND AUDIO* from SDL. */
desired.freq = p_aout->i_rate;
desired.format = AUDIO_S16LSB; /* stereo 16 bits */ desired.format = AUDIO_S16LSB; /* stereo 16 bits */
desired.channels = i_channels; desired.channels = p_aout->i_channels;
desired.callback = aout_SDLCallback; desired.callback = aout_SDLCallback;
desired.userdata = p_aout->p_sys; desired.userdata = p_aout->p_sys;
desired.samples = 1024; desired.samples = 1024;
...@@ -171,12 +170,11 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -171,12 +170,11 @@ static int aout_SetFormat( aout_thread_t *p_aout )
{ {
/* TODO: finish and clean this */ /* TODO: finish and clean this */
SDL_AudioSpec desired; SDL_AudioSpec desired;
int i_stereo = p_aout->b_stereo ? 2 : 1;
/*i_format = p_aout->i_format;*/ /*i_format = p_aout->i_format;*/
desired.freq = p_aout->l_rate; /* Set the output rate */ desired.freq = p_aout->i_rate; /* Set the output rate */
desired.format = AUDIO_S16LSB; /* stereo 16 bits */ desired.format = AUDIO_S16LSB; /* stereo 16 bits */
desired.channels = i_stereo; desired.channels = p_aout->i_channels;
desired.callback = aout_SDLCallback; desired.callback = aout_SDLCallback;
desired.userdata = p_aout->p_sys; desired.userdata = p_aout->p_sys;
desired.samples = 2048; desired.samples = 2048;
...@@ -201,16 +199,16 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -201,16 +199,16 @@ static int aout_SetFormat( aout_thread_t *p_aout )
* aout_GetBufInfo: buffer status query * aout_GetBufInfo: buffer status query
***************************************************************************** *****************************************************************************
* returns the number of bytes in the audio buffer compared to the size of * returns the number of bytes in the audio buffer compared to the size of
* l_buffer_limit... * i_buffer_limit...
*****************************************************************************/ *****************************************************************************/
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 )
{ {
if(l_buffer_limit > p_aout->p_sys->i_audio_end) if(i_buffer_limit > p_aout->p_sys->i_audio_end)
{ {
/* returning 0 here juste gives awful sound in the speakers :/ */ /* returning 0 here juste gives awful sound in the speakers :/ */
return( l_buffer_limit ); return( i_buffer_limit );
} }
return( p_aout->p_sys->i_audio_end - l_buffer_limit); return( p_aout->p_sys->i_audio_end - i_buffer_limit);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* waveout.c : Windows waveOut plugin for vlc * waveout.c : Windows waveOut plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: waveout.c,v 1.3 2002/02/24 20:51:10 gbazin Exp $ * $Id: waveout.c,v 1.4 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Gildas Bazin <gbazin@netcourrier.com> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* *
...@@ -88,7 +88,7 @@ typedef struct aout_sys_s ...@@ -88,7 +88,7 @@ typedef struct aout_sys_s
*****************************************************************************/ *****************************************************************************/
static int aout_Open ( aout_thread_t *p_aout ); static int aout_Open ( aout_thread_t *p_aout );
static int aout_SetFormat ( 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, static void aout_Play ( aout_thread_t *p_aout,
byte_t *buffer, int i_size ); byte_t *buffer, int i_size );
static void aout_Close ( aout_thread_t *p_aout ); static void aout_Close ( aout_thread_t *p_aout );
...@@ -153,7 +153,7 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -153,7 +153,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
/* Check if the format has changed */ /* Check if the format has changed */
if( (p_aout->p_sys->waveformat.nChannels != p_aout->i_channels) || if( (p_aout->p_sys->waveformat.nChannels != p_aout->i_channels) ||
(p_aout->p_sys->waveformat.nSamplesPerSec != p_aout->l_rate) ) (p_aout->p_sys->waveformat.nSamplesPerSec != p_aout->i_rate) )
{ {
if( waveOutClose( p_aout->p_sys->h_waveout ) == MMSYSERR_NOERROR ) if( waveOutClose( p_aout->p_sys->h_waveout ) == MMSYSERR_NOERROR )
{ {
...@@ -172,7 +172,7 @@ static int aout_SetFormat( aout_thread_t *p_aout ) ...@@ -172,7 +172,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
* returns the number of bytes in the audio buffer that have not yet been * returns the number of bytes in the audio buffer that have not yet been
* sent to the sound device. * 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 )
{ {
MMTIME mmtime; MMTIME mmtime;
...@@ -181,7 +181,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit ) ...@@ -181,7 +181,7 @@ static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
!= MMSYSERR_NOERROR || (mmtime.wType != TIME_BYTES) ) != MMSYSERR_NOERROR || (mmtime.wType != TIME_BYTES) )
{ {
intf_WarnMsg( 3, "aout: aout_GetBufInfo waveOutGetPosition failed"); intf_WarnMsg( 3, "aout: aout_GetBufInfo waveOutGetPosition failed");
return l_buffer_limit; return i_buffer_limit;
} }
...@@ -281,7 +281,7 @@ static int OpenWaveOutDevice( aout_thread_t *p_aout ) ...@@ -281,7 +281,7 @@ static int OpenWaveOutDevice( aout_thread_t *p_aout )
/* Set sound format */ /* Set sound format */
p_aout->p_sys->waveformat.wFormatTag = WAVE_FORMAT_PCM; p_aout->p_sys->waveformat.wFormatTag = WAVE_FORMAT_PCM;
p_aout->p_sys->waveformat.nChannels = p_aout->i_channels; p_aout->p_sys->waveformat.nChannels = p_aout->i_channels;
p_aout->p_sys->waveformat.nSamplesPerSec = p_aout->l_rate; p_aout->p_sys->waveformat.nSamplesPerSec = p_aout->i_rate;
p_aout->p_sys->waveformat.wBitsPerSample = 16; p_aout->p_sys->waveformat.wBitsPerSample = 16;
p_aout->p_sys->waveformat.nBlockAlign = p_aout->p_sys->waveformat.nBlockAlign =
p_aout->p_sys->waveformat.wBitsPerSample / 8 * p_aout->i_channels; p_aout->p_sys->waveformat.wBitsPerSample / 8 * p_aout->i_channels;
......
/*****************************************************************************
* aout_common.h: audio output inner functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: aout_common.h,v 1.9 2002/01/15 11:51:11 asmax Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/* Biggest difference allowed between scheduled playing date and actual date
(in microseconds) */
#define MAX_DELTA 10000
/* Creating as many aout_Thread functions as configurations was one solution,
* examining the different cases in the Thread loop of an unique function was
* another. I chose the first solution. */
void aout_U8Thread ( aout_thread_t * p_aout );
void aout_S8Thread ( aout_thread_t * p_aout );
void aout_U16Thread ( aout_thread_t * p_aout );
void aout_S16Thread ( aout_thread_t * p_aout );
void aout_SpdifThread ( aout_thread_t * p_aout );
void aout_FillBuffer ( aout_thread_t * p_aout, aout_fifo_t * p_fifo );
/* Generic main thread function "aout_XXXThread"
*/
#define DECLARE_AOUT_THREAD( format, type, buffer_copy ) \
void aout_##format##Thread( aout_thread_t * p_aout ) \
{ \
\
int i_fifo; \
long l_buffer, l_buffer_limit, l_bytes; \
\
/* As the s32_buffer was created with calloc(), we don't have to set this \
* memory to zero and we can immediately jump into the thread's loop */ \
while ( ! p_aout->b_die ) \
{ \
vlc_mutex_lock( &p_aout->fifos_lock ); \
\
for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) \
{ \
if( p_aout->fifo[i_fifo].b_die ) \
{ \
aout_FreeFifo( &p_aout->fifo[i_fifo] ); \
} \
else \
{ \
aout_FillBuffer( p_aout, &p_aout->fifo[i_fifo] ); \
} \
} \
\
vlc_mutex_unlock( &p_aout->fifos_lock ); \
\
l_buffer_limit = p_aout->l_units << p_aout->b_stereo; \
\
for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ ) \
{ \
((type *)p_aout->buffer)[l_buffer] = (type)( buffer_copy * \
p_aout->i_volume / 256 ); \
p_aout->s32_buffer[l_buffer] = 0; \
} \
\
l_bytes = p_aout->pf_getbufinfo( p_aout, l_buffer_limit ); \
\
p_aout->date = mdate() + ((((mtime_t)((l_bytes + 4 * \
p_aout->i_latency) / \
(sizeof(type) << p_aout->b_stereo))) * 1000000) / \
((mtime_t)p_aout->l_rate)) + p_main->i_desync; \
\
p_aout->pf_play( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * \
sizeof(type) ); \
\
if ( l_bytes > (l_buffer_limit * sizeof(type)) ) \
{ \
msleep( p_aout->l_msleep ); \
} \
} \
\
vlc_mutex_lock( &p_aout->fifos_lock ); \
\
for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) \
{ \
aout_FreeFifo( &p_aout->fifo[i_fifo] ); \
} \
\
vlc_mutex_unlock( &p_aout->fifos_lock ); \
\
} \
/*****************************************************************************
* InitializeIncrement
*****************************************************************************/
static __inline__ void InitializeIncrement( aout_increment_t * p_increment,
long l_numerator,
long l_denominator )
{
p_increment->l_remainder = -l_denominator;
p_increment->l_euclidean_integer = 0;
while ( l_numerator >= l_denominator )
{
p_increment->l_euclidean_integer++;
l_numerator -= l_denominator;
}
p_increment->l_euclidean_remainder = l_numerator;
p_increment->l_euclidean_denominator = l_denominator;
}
/*****************************************************************************
* UpdateIncrement
*****************************************************************************/
static __inline__ void UpdateIncrement( aout_increment_t * p_increment,
long * p_integer )
{
if( (p_increment->l_remainder += p_increment->l_euclidean_remainder) >= 0 )
{
*p_integer += p_increment->l_euclidean_integer + 1;
p_increment->l_remainder -= p_increment->l_euclidean_denominator;
}
else
{
*p_integer += p_increment->l_euclidean_integer;
}
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_ext-dec.c : exported fifo management functions * aout_ext-dec.c : exported fifo management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: aout_ext-dec.c,v 1.12 2002/02/15 13:32:54 sam Exp $ * $Id: aout_ext-dec.c,v 1.13 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr> * Cyril Deguet <asmax@via.ecp.fr>
...@@ -32,21 +32,16 @@ ...@@ -32,21 +32,16 @@
#include <videolan/vlc.h> #include <videolan/vlc.h>
#include "audio_output.h" #include "audio_output.h"
#include "aout_common.h"
/***************************************************************************** /*****************************************************************************
* aout_CreateFifo * aout_CreateFifo
*****************************************************************************/ *****************************************************************************/
aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate, aout_fifo_t * aout_CreateFifo( int i_format, int i_channels, int i_rate,
long l_units, long l_frame_size, int i_frame_size, void *p_buffer )
void *p_buffer )
{ {
aout_thread_t *p_aout; aout_thread_t *p_aout;
int i_fifo; aout_fifo_t *p_fifo = NULL;
int i_index;
intf_WarnMsg( 3, "aout info: fifo type %d, %d channels, rate %d, "
"%d units, frame size %d",
i_type, i_channels, l_rate, l_units, l_frame_size );
/* Spawn an audio output if there is none */ /* Spawn an audio output if there is none */
vlc_mutex_lock( &p_aout_bank->lock ); vlc_mutex_lock( &p_aout_bank->lock );
...@@ -55,7 +50,7 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate, ...@@ -55,7 +50,7 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate,
{ {
intf_WarnMsg( 1, "aout: no aout present, spawning one" ); intf_WarnMsg( 1, "aout: no aout present, spawning one" );
p_aout = aout_CreateThread( NULL, i_channels, l_rate ); p_aout = aout_CreateThread( NULL, i_channels, i_rate );
/* Everything failed */ /* Everything failed */
if( p_aout == NULL ) if( p_aout == NULL )
...@@ -69,13 +64,13 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate, ...@@ -69,13 +64,13 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate,
} }
/* temporary hack to switch output type (mainly for spdif) /* temporary hack to switch output type (mainly for spdif)
* FIXME: to be adapted when several output are available */ * FIXME: to be adapted when several output are available */
else if( p_aout_bank->pp_aout[0]->fifo[0].i_type != i_type ) else if( p_aout_bank->pp_aout[0]->fifo[0].i_format != i_format )
{ {
intf_WarnMsg( 1, "aout: changing aout type" ); intf_WarnMsg( 1, "aout: changing aout type" );
aout_DestroyThread( p_aout_bank->pp_aout[0], NULL ); aout_DestroyThread( p_aout_bank->pp_aout[0], NULL );
p_aout = aout_CreateThread( NULL, i_channels, l_rate ); p_aout = aout_CreateThread( NULL, i_channels, i_rate );
/* Everything failed */ /* Everything failed */
if( p_aout == NULL ) if( p_aout == NULL )
...@@ -85,7 +80,6 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate, ...@@ -85,7 +80,6 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate,
} }
p_aout_bank->pp_aout[0] = p_aout; p_aout_bank->pp_aout[0] = p_aout;
} }
else else
{ {
...@@ -96,18 +90,18 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate, ...@@ -96,18 +90,18 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate,
/* Take the fifos lock */ /* Take the fifos lock */
vlc_mutex_lock( &p_aout->fifos_lock ); vlc_mutex_lock( &p_aout->fifos_lock );
/* Looking for a free fifo structure */ /* Look for a free fifo structure */
for( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) for( i_index = 0; i_index < AOUT_MAX_FIFOS; i_index++ )
{ {
if( p_aout->fifo[i_fifo].i_type == AOUT_EMPTY_FIFO ) if( p_aout->fifo[i_index].i_format == AOUT_FIFO_NONE )
{ {
/* Not very clever, but at least we know which fifo it is */ p_fifo = &p_aout->fifo[i_index];
p_aout->fifo[i_fifo].i_fifo = i_fifo; p_fifo->i_fifo = i_index;
break; break;
} }
} }
if( i_fifo == AOUT_MAX_FIFOS ) if( p_fifo == NULL )
{ {
intf_ErrMsg( "aout error: no fifo available" ); intf_ErrMsg( "aout error: no fifo available" );
vlc_mutex_unlock( &p_aout->fifos_lock ); vlc_mutex_unlock( &p_aout->fifos_lock );
...@@ -116,65 +110,56 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate, ...@@ -116,65 +110,56 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate,
} }
/* Initialize the new fifo structure */ /* Initialize the new fifo structure */
switch ( p_aout->fifo[i_fifo].i_type = i_type ) switch ( p_fifo->i_format = i_format )
{ {
case AOUT_ADEC_MONO_FIFO: case AOUT_FIFO_PCM:
case AOUT_ADEC_STEREO_FIFO: case AOUT_FIFO_SPDIF:
case AOUT_ADEC_SPDIF_FIFO: p_fifo->b_die = 0;
p_aout->fifo[i_fifo].b_die = 0;
p_fifo->i_channels = i_channels;
p_aout->fifo[i_fifo].i_channels = i_channels; p_fifo->i_rate = i_rate;
p_aout->fifo[i_fifo].b_stereo = ( i_channels == 2 ); p_fifo->i_frame_size = i_frame_size;
p_aout->fifo[i_fifo].l_rate = l_rate;
p_fifo->i_unit_limit = (AOUT_FIFO_SIZE + 1)
p_aout->fifo[i_fifo].l_frame_size = l_frame_size; * (i_frame_size / i_channels);
/* Allocate the memory needed to store the audio frames. As the
* fifo is a rotative fifo, we must be able to find out whether /* Allocate the memory needed to store the audio frames and their
* the fifo is full or empty, that's why we must in fact allocate * dates. As the fifo is a rotative fifo, we must be able to find
* memory for (AOUT_FIFO_SIZE+1) audio frames. */ * out whether the fifo is full or empty, that's why we must in
p_aout->fifo[i_fifo].buffer = malloc( sizeof(s16) * * fact allocate memory for (AOUT_FIFO_SIZE+1) audio frames. */
( AOUT_FIFO_SIZE + 1 ) * l_frame_size ); p_fifo->date = malloc( ( sizeof(s16) * i_frame_size
if ( p_aout->fifo[i_fifo].buffer == NULL ) + sizeof(mtime_t) )
* ( AOUT_FIFO_SIZE + 1 ) );
if ( p_fifo->date == NULL )
{ {
intf_ErrMsg( "aout error: cannot create frame buffer" ); intf_ErrMsg( "aout error: cannot create fifo data" );
p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; p_fifo->i_format = AOUT_FIFO_NONE;
vlc_mutex_unlock( &p_aout->fifos_lock ); vlc_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout_bank->lock ); vlc_mutex_unlock( &p_aout_bank->lock );
return( NULL ); return( NULL );
} }
/* Allocate the memory needed to store the dates of the frames */ p_fifo->buffer = (void *)p_fifo->date + sizeof(mtime_t)
p_aout->fifo[i_fifo].date = * ( AOUT_FIFO_SIZE + 1 );
malloc( sizeof(mtime_t) * ( AOUT_FIFO_SIZE + 1) );
if ( p_aout->fifo[i_fifo].date == NULL )
{
intf_ErrMsg( "aout error: cannot create date buffer");
free( p_aout->fifo[i_fifo].buffer );
p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
vlc_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout_bank->lock );
return( NULL );
}
/* Set the fifo's buffer as empty (the first frame that is to be /* Set the fifo's buffer as empty (the first frame that is to be
* played is also the first frame that is not to be played) */ * played is also the first frame that is not to be played) */
p_aout->fifo[i_fifo].l_start_frame = 0; p_fifo->i_start_frame = 0;
/* p_aout->fifo[i_fifo].l_next_frame = 0; */ /* p_fifo->i_next_frame = 0; */
p_aout->fifo[i_fifo].l_end_frame = 0; p_fifo->i_end_frame = 0;
/* Waiting for the audio decoder to compute enough frames to work /* Waiting for the audio decoder to compute enough frames to work
* out the fifo's current rate (as soon as the decoder has decoded * out the fifo's current rate (as soon as the decoder has decoded
* enough frames, the members of the fifo structure that are not * enough frames, the members of the fifo structure that are not
* initialized now will be calculated) */ * initialized now will be calculated) */
p_aout->fifo[i_fifo].b_start_frame = 0; p_fifo->b_start_frame = 0;
p_aout->fifo[i_fifo].b_next_frame = 0; p_fifo->b_next_frame = 0;
break; break;
default: default:
intf_ErrMsg( "aout error: unknown fifo type 0x%x", intf_ErrMsg( "aout error: unknown fifo type 0x%x",
p_aout->fifo[i_fifo].i_type ); p_fifo->i_format );
p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; p_fifo->i_format = AOUT_FIFO_NONE;
vlc_mutex_unlock( &p_aout->fifos_lock ); vlc_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout_bank->lock ); vlc_mutex_unlock( &p_aout_bank->lock );
return( NULL ); return( NULL );
...@@ -184,12 +169,12 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate, ...@@ -184,12 +169,12 @@ aout_fifo_t * aout_CreateFifo( int i_type, int i_channels, long l_rate,
vlc_mutex_unlock( &p_aout->fifos_lock ); vlc_mutex_unlock( &p_aout->fifos_lock );
vlc_mutex_unlock( &p_aout_bank->lock ); vlc_mutex_unlock( &p_aout_bank->lock );
intf_WarnMsg( 2, "aout info: fifo #%i allocated, %i channels, rate %li", intf_WarnMsg( 2, "aout info: fifo #%i allocated, %i channels, rate %li, "
p_aout->fifo[i_fifo].i_fifo, p_aout->fifo[i_fifo].i_channels, "frame size %i", p_fifo->i_fifo, p_fifo->i_channels,
p_aout->fifo[i_fifo].l_rate ); p_fifo->i_rate, p_fifo->i_frame_size );
/* Return the pointer to the fifo structure */ /* Return the pointer to the fifo structure */
return( &p_aout->fifo[i_fifo] ); return( p_fifo );
} }
/***************************************************************************** /*****************************************************************************
...@@ -207,19 +192,17 @@ void aout_DestroyFifo( aout_fifo_t * p_fifo ) ...@@ -207,19 +192,17 @@ void aout_DestroyFifo( aout_fifo_t * p_fifo )
*****************************************************************************/ *****************************************************************************/
void aout_FreeFifo( aout_fifo_t * p_fifo ) void aout_FreeFifo( aout_fifo_t * p_fifo )
{ {
switch ( p_fifo->i_type ) switch ( p_fifo->i_format )
{ {
case AOUT_EMPTY_FIFO: case AOUT_FIFO_NONE:
break; break;
case AOUT_ADEC_MONO_FIFO: case AOUT_FIFO_PCM:
case AOUT_ADEC_STEREO_FIFO: case AOUT_FIFO_SPDIF:
case AOUT_ADEC_SPDIF_FIFO:
free( p_fifo->buffer );
free( p_fifo->date ); free( p_fifo->date );
p_fifo->i_type = AOUT_EMPTY_FIFO; p_fifo->i_format = AOUT_FIFO_NONE;
break; break;
......
/*****************************************************************************
* aout_pcm.h: PCM audio output functions
*****************************************************************************
* Copyright (C) 1999-2002 VideoLAN
* $Id: aout_pcm.h,v 1.1 2002/02/24 22:06:50 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
void aout_PCMThread( aout_thread_t * p_aout );
/***************************************************************************** /*****************************************************************************
* aout_spdif: ac3 passthrough output * aout_spdif.c: AC3 passthrough output
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: aout_spdif.c,v 1.22 2002/02/19 00:50:19 sam Exp $ * $Id: aout_spdif.c,v 1.23 2002/02/24 22:06:50 sam Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <videolan/vlc.h> #include <videolan/vlc.h>
#include "audio_output.h" #include "audio_output.h"
#include "aout_common.h" #include "aout_spdif.h"
/***************************************************************************** /*****************************************************************************
* aout_SpdifThread: audio output thread that sends raw spdif data * aout_SpdifThread: audio output thread that sends raw spdif data
...@@ -51,7 +51,6 @@ void aout_SpdifThread( aout_thread_t * p_aout ) ...@@ -51,7 +51,6 @@ void aout_SpdifThread( aout_thread_t * p_aout )
mtime_t m_play; mtime_t m_play;
mtime_t m_old = 0; mtime_t m_old = 0;
while( !p_aout->b_die ) while( !p_aout->b_die )
{ {
for( i_fifo = 0 ; i_fifo < AOUT_MAX_FIFOS ; i_fifo++ ) for( i_fifo = 0 ; i_fifo < AOUT_MAX_FIFOS ; i_fifo++ )
...@@ -60,7 +59,7 @@ void aout_SpdifThread( aout_thread_t * p_aout ) ...@@ -60,7 +59,7 @@ void aout_SpdifThread( aout_thread_t * p_aout )
* on the fly but mulitplexing is not handled yet so * on the fly but mulitplexing is not handled yet so
* the sound will be broken is more than one fifo has data */ * the sound will be broken is more than one fifo has data */
/* TODO: write the muliplexer :) */ /* TODO: write the muliplexer :) */
if( p_aout->fifo[i_fifo].i_type == AOUT_ADEC_SPDIF_FIFO ) if( p_aout->fifo[i_fifo].i_format == AOUT_FIFO_SPDIF )
{ {
vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock ); vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
if( p_aout->fifo[i_fifo].b_die ) if( p_aout->fifo[i_fifo].b_die )
...@@ -73,23 +72,24 @@ void aout_SpdifThread( aout_thread_t * p_aout ) ...@@ -73,23 +72,24 @@ void aout_SpdifThread( aout_thread_t * p_aout )
} }
else if( !AOUT_FIFO_ISEMPTY( p_aout->fifo[i_fifo] ) ) else if( !AOUT_FIFO_ISEMPTY( p_aout->fifo[i_fifo] ) )
{ {
/* Copy data from fifo to buffer to release the lock earlier */ /* Copy data from fifo to buffer to release the
memcpy( p_aout->buffer, * lock earlier */
FAST_MEMCPY( p_aout->buffer,
(byte_t *)p_aout->fifo[i_fifo].buffer (byte_t *)p_aout->fifo[i_fifo].buffer
+ p_aout->fifo[i_fifo].l_start_frame + p_aout->fifo[i_fifo].i_start_frame
* SPDIF_FRAME_SIZE, * SPDIF_FRAME_SIZE,
SPDIF_FRAME_SIZE ); SPDIF_FRAME_SIZE );
m_play = p_aout->fifo[i_fifo].date[p_aout->fifo[i_fifo]. m_play = p_aout->fifo[i_fifo].date[p_aout->fifo[i_fifo].
l_start_frame]; i_start_frame];
p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].i_start_frame =
(p_aout->fifo[i_fifo].l_start_frame + 1 ) (p_aout->fifo[i_fifo].i_start_frame + 1 )
& AOUT_FIFO_SIZE; & AOUT_FIFO_SIZE;
/* Compute the theorical duration of an ac3 frame */ /* Compute the theorical duration of an ac3 frame */
m_frame_time = 1000000 * AC3_FRAME_SIZE m_frame_time = 1000000 * AC3_FRAME_SIZE
/ p_aout->fifo[i_fifo].l_rate; / p_aout->fifo[i_fifo].i_rate;
vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock ); vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
...@@ -109,8 +109,7 @@ void aout_SpdifThread( aout_thread_t * p_aout ) ...@@ -109,8 +109,7 @@ void aout_SpdifThread( aout_thread_t * p_aout )
} }
m_old = m_play; m_old = m_play;
p_aout->pf_play( p_aout, p_aout->pf_play( p_aout, (byte_t *)p_aout->buffer,
(byte_t *)p_aout->buffer,
SPDIF_FRAME_SIZE ); SPDIF_FRAME_SIZE );
} }
} }
...@@ -125,12 +124,10 @@ void aout_SpdifThread( aout_thread_t * p_aout ) ...@@ -125,12 +124,10 @@ void aout_SpdifThread( aout_thread_t * p_aout )
} }
vlc_mutex_lock( &p_aout->fifos_lock ); vlc_mutex_lock( &p_aout->fifos_lock );
for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
{ {
aout_FreeFifo( &p_aout->fifo[i_fifo] ); aout_FreeFifo( &p_aout->fifo[i_fifo] );
} }
vlc_mutex_unlock( &p_aout->fifos_lock ); vlc_mutex_unlock( &p_aout->fifos_lock );
return; return;
......
This diff is collapsed.
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