Commit 60754f11 authored by Stéphane Borel's avatar Stéphane Borel

-Fixed ac3_spdif which has been broken recently,

-Check frequency in ac3_adec and change fifo if needed,

-Moved initialisation of p_aout from plugins to audio_output.c
If audio output rate is psecified at launch time, we try to use it by default.

Note that audio output currently suffers from frequent underruns.
This has not been fixed here.
parent bdeea764
......@@ -2,7 +2,7 @@
* ac3_adec.c: ac3 decoder module main file
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: ac3_adec.c,v 1.17 2002/01/23 23:14:59 massiot Exp $
* $Id: ac3_adec.c,v 1.18 2002/01/28 23:08:31 stef Exp $
*
* Authors: Michel Lespinasse <walken@zoy.org>
*
......@@ -278,6 +278,19 @@ static int decoder_Run ( decoder_config_t * p_config )
b_sync = 0;
continue;
}
if( ( p_ac3thread->p_aout_fifo != NULL ) &&
( p_ac3thread->p_aout_fifo->l_rate != sync_info.sample_rate ) )
{
aout_DestroyFifo (p_ac3thread->p_aout_fifo);
/* Make sure the output thread leaves the NextFrame() function */
vlc_mutex_lock (&(p_ac3thread->p_aout_fifo->data_lock));
vlc_cond_signal (&(p_ac3thread->p_aout_fifo->data_wait));
vlc_mutex_unlock (&(p_ac3thread->p_aout_fifo->data_lock));
p_ac3thread->p_aout_fifo = NULL;
}
/* Creating the audio output fifo if not created yet */
if (p_ac3thread->p_aout_fifo == NULL ) {
......
......@@ -2,7 +2,7 @@
* ac3_spdif.c: ac3 pass-through to external decoder with enabled soundcard
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: ac3_spdif.c,v 1.11 2002/01/21 23:57:46 massiot Exp $
* $Id: ac3_spdif.c,v 1.12 2002/01/28 23:08:31 stef Exp $
*
* Authors: Stphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi>
......@@ -232,18 +232,6 @@ static int InitThread( ac3_spdif_thread_t * p_spdif )
InitBitstream( &p_spdif->bit_stream, p_spdif->p_config->p_decoder_fifo,
BitstreamCallback, (void*)p_spdif );
/* Creating the audio output fifo */
p_spdif->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_SPDIF_FIFO, 1, 48000, 0,
SPDIF_FRAME_SIZE, NULL );
if( p_spdif->p_aout_fifo == NULL )
{
return( -1 );
}
intf_WarnMsg( 3, "spdif: aout fifo #%d created",
p_spdif->p_aout_fifo->i_fifo );
/* Sync word */
p_spdif->p_ac3[0] = 0x0b;
p_spdif->p_ac3[1] = 0x77;
......@@ -272,12 +260,26 @@ static int InitThread( ac3_spdif_thread_t * p_spdif )
* but all rates should be supported by the decoder (32, 44.1, 48) */
if( p_spdif->ac3_info.i_sample_rate != 48000 )
{
intf_ErrMsg( "spdif error: Only 48000 Hz streams supported");
intf_ErrMsg( "spdif error: Only 48000 Hz streams tested"
"expect weird things !" );
//intf_ErrMsg( "spdif error: Only 48000 Hz streams supported");
aout_DestroyFifo( p_spdif->p_aout_fifo );
return -1;
//aout_DestroyFifo( p_spdif->p_aout_fifo );
//return -1;
}
p_spdif->p_aout_fifo->l_rate = p_spdif->ac3_info.i_sample_rate;
/* Creating the audio output fifo */
p_spdif->p_aout_fifo = aout_CreateFifo( AOUT_ADEC_SPDIF_FIFO, 1,
p_spdif->ac3_info.i_sample_rate,
0, SPDIF_FRAME_SIZE, NULL );
if( p_spdif->p_aout_fifo == NULL )
{
return( -1 );
}
intf_WarnMsg( 3, "spdif: aout fifo #%d created",
p_spdif->p_aout_fifo->i_fifo );
GetChunk( &p_spdif->bit_stream, p_spdif->p_ac3 + sizeof(sync_frame_t),
p_spdif->ac3_info.i_frame_size - sizeof(sync_frame_t) );
......
......@@ -2,7 +2,7 @@
* aout_alsa.c : Alsa functions library
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: aout_alsa.c,v 1.24 2001/12/30 07:09:54 sam Exp $
* $Id: aout_alsa.c,v 1.25 2002/01/28 23:08:31 stef Exp $
*
* Authors: Henri Fallon <henri@videolan.org> - Original Author
* Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API
......@@ -116,12 +116,6 @@ static int aout_Open( aout_thread_t *p_aout )
return( 1 );
}
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
AOUT_STEREO_DEFAULT );
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR,
AOUT_RATE_DEFAULT );
/* Open device */
if( ( i_open_returns = snd_pcm_open(&(p_aout->p_sys->p_alsa_handle),
"default",
......@@ -263,8 +257,6 @@ static int aout_SetFormat( aout_thread_t *p_aout )
return( -1 );
}
p_aout->i_latency = 0;
return( 0 );
}
......
......@@ -2,7 +2,7 @@
* aout_beos.cpp: BeOS audio output
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: aout_beos.cpp,v 1.18 2001/12/30 07:09:54 sam Exp $
* $Id: aout_beos.cpp,v 1.19 2002/01/28 23:08:31 stef Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -121,11 +121,6 @@ static int aout_Open( aout_thread_t *p_aout )
}
/* Initialize some variables */
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
AOUT_STEREO_DEFAULT );
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT );
p_aout->p_sys->p_format->frame_rate = 44100.0;
p_aout->p_sys->p_format->channel_count = p_aout->i_channels;
p_aout->p_sys->p_format->format = gs_audio_format::B_GS_S16;
......@@ -166,8 +161,6 @@ static int aout_Open( aout_thread_t *p_aout )
*****************************************************************************/
static int aout_SetFormat( aout_thread_t *p_aout )
{
p_aout->i_latency = 0;
return( 0 );
}
......
......@@ -2,7 +2,7 @@
* aout_directx.c: Windows DirectX audio output method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: aout_directx.c,v 1.15 2002/01/17 23:02:45 gbazin Exp $
* $Id: aout_directx.c,v 1.16 2002/01/28 23:08:31 stef Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -164,11 +164,6 @@ static int aout_Open( aout_thread_t *p_aout )
p_aout->psz_device = 0;
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
AOUT_STEREO_DEFAULT );
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR,
AOUT_RATE_DEFAULT );
/* Initialise DirectSound */
if( DirectxInitDSound( p_aout ) )
......@@ -286,8 +281,6 @@ static int aout_SetFormat( aout_thread_t *p_aout )
vlc_mutex_unlock( &p_aout->p_sys->buffer_lock );
p_aout->i_latency = 0;
return( 0 );
}
......
......@@ -2,7 +2,7 @@
* aout_dsp.c : dsp functions library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: aout_dsp.c,v 1.19 2002/01/09 00:33:37 asmax Exp $
* $Id: aout_dsp.c,v 1.20 2002/01/28 23:08:31 stef Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -132,14 +132,6 @@ static int aout_Open( aout_thread_t *p_aout )
/* Initialize some variables */
p_aout->psz_device = main_GetPszVariable( AOUT_DSP_VAR, AOUT_DSP_DEFAULT );
p_aout->i_format = AOUT_FORMAT_DEFAULT;
/* All that is drawn directly from the audio stream.
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
AOUT_STEREO_DEFAULT );
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR,
AOUT_RATE_DEFAULT );
*/
/* Open the sound device */
if( (p_aout->i_fd = open( p_aout->psz_device, O_WRONLY )) < 0 )
......@@ -222,8 +214,6 @@ static int aout_SetFormat( aout_thread_t *p_aout )
p_aout->l_rate = l_rate;
}
p_aout->i_latency = 0;
return( 0 );
}
......
......@@ -2,7 +2,7 @@
* aout_dummy.c : dummy audio output plugin
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: aout_dummy.c,v 1.17 2001/12/30 07:09:55 sam Exp $
* $Id: aout_dummy.c,v 1.18 2002/01/28 23:08:31 stef Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -81,13 +81,6 @@ static int aout_Probe( probedata_t *p_data )
*****************************************************************************/
static int aout_Open( aout_thread_t *p_aout )
{
/* Initialize some variables */
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
AOUT_STEREO_DEFAULT );
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR,
AOUT_RATE_DEFAULT );
return( 0 );
}
......@@ -96,8 +89,6 @@ static int aout_Open( aout_thread_t *p_aout )
*****************************************************************************/
static int aout_SetFormat( aout_thread_t *p_aout )
{
p_aout->i_latency = 0;
return( 0 );
}
......
......@@ -2,7 +2,7 @@
* aout_esd.c : Esound functions library
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: aout_esd.c,v 1.17 2001/12/30 07:09:55 sam Exp $
* $Id: aout_esd.c,v 1.18 2002/01/28 23:08:31 stef Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -112,8 +112,6 @@ static int aout_Open( aout_thread_t *p_aout )
}
/* Initialize some variables */
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR, AOUT_STEREO_DEFAULT );
p_aout->l_rate = esd_audio_rate; /* We use actual esd rate value, not AOUT_RATE_DEFAULT */
i_bits = ESD_BITS16;
......
......@@ -2,7 +2,7 @@
* aout_darwin.c : Darwin audio output plugin
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: aout_macosx.c,v 1.10 2002/01/19 19:54:01 gbazin Exp $
* $Id: aout_macosx.c,v 1.11 2002/01/28 23:08:31 stef Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
*
......@@ -141,12 +141,6 @@ static int aout_Open( aout_thread_t *p_aout )
}
/* Initialize some variables */
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
AOUT_STEREO_DEFAULT );
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR,
AOUT_RATE_DEFAULT );
p_aout->p_sys->device = kAudioDeviceUnknown;
p_aout->p_sys->p_Data = nil;
......@@ -322,8 +316,6 @@ static int aout_SetFormat( aout_thread_t *p_aout )
}
}
p_aout->i_latency = 0;
/* add callback */
err = AudioDeviceAddIOProc( p_aout->p_sys->device,
(AudioDeviceIOProc)appIOProc,
......
......@@ -118,13 +118,6 @@ static int aout_Open( aout_thread_t *p_aout )
return( 1 );
}
/* initialize */
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->i_channels = main_GetIntVariable( AOUT_STEREO_VAR,
AOUT_STEREO_DEFAULT ) + 1;
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR,
AOUT_RATE_DEFAULT );
/* open audio device */
if( ( i_ret = snd_pcm_open_preferred( &p_aout->p_sys->p_pcm_handle,
&p_aout->p_sys->i_card,
......@@ -222,8 +215,6 @@ static int aout_SetFormat( aout_thread_t *p_aout )
return( 1 );
}
p_aout->i_latency = 0;
return( 0 );
}
......
......@@ -2,7 +2,7 @@
* aout_sdl.c : audio sdl functions library
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: aout_sdl.c,v 1.23 2002/01/04 14:01:34 sam Exp $
* $Id: aout_sdl.c,v 1.24 2002/01/28 23:08:31 stef Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -181,12 +181,6 @@ static int aout_Open( aout_thread_t *p_aout )
/* Initialize some variables */
p_aout->psz_device = 0;
p_aout->i_format = AOUT_FORMAT_DEFAULT;
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
AOUT_STEREO_DEFAULT );
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR,
AOUT_RATE_DEFAULT );
desired.freq = p_aout->l_rate;
/* TODO: write conversion beetween AOUT_FORMAT_DEFAULT
......@@ -251,8 +245,6 @@ static int aout_SetFormat( aout_thread_t *p_aout )
p_aout->p_sys->b_active = 1;
SDL_PauseAudio( 0 );
p_aout->i_latency = 0;
return( 0 );
}
......
......@@ -2,7 +2,7 @@
* aout_waveout.c: Windows waveOut audio output method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: aout_waveout.c,v 1.1 2002/01/25 06:43:34 gbazin Exp $
* $Id: aout_waveout.c,v 1.2 2002/01/28 23:08:31 stef Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -147,9 +147,7 @@ static int aout_Open( aout_thread_t *p_aout )
for( i=0; i<NUMBUF; i++)
p_aout->p_sys->waveheader[i].lpData = malloc( 1 );
p_aout->i_latency = 0;
p_aout->psz_device = 0;
p_aout->i_format = AOUT_FORMAT_DEFAULT;
return OpenWaveOutDevice( p_aout );
......
......@@ -2,7 +2,7 @@
* audio_output.c : audio output thread
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: audio_output.c,v 1.74 2002/01/25 06:43:34 gbazin Exp $
* $Id: audio_output.c,v 1.75 2002/01/28 23:08:31 stef Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -92,8 +92,17 @@ aout_thread_t *aout_CreateThread( int *pi_status, int i_channels, long l_rate )
return( NULL );
}
p_aout->l_rate = l_rate;
p_aout->i_channels = i_channels;
p_aout->i_latency = 0;
p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR, l_rate );
p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
i_channels - 1 );
intf_WarnMsg( 3, "aout_CreateThread: channels == %d, rate == %d",
p_aout->i_channels,
p_aout->l_rate );
/* Maybe we should pass this setting in argument */
p_aout->i_format = AOUT_FORMAT_DEFAULT;
/* special setting for ac3 pass-through mode */
/* FIXME is it necessary ? (cf ac3_adec.c) */
......@@ -101,9 +110,8 @@ aout_thread_t *aout_CreateThread( int *pi_status, int i_channels, long l_rate )
{
intf_WarnMsg( 4, "aout info: setting ac3 spdif" );
p_aout->i_format = AOUT_FMT_AC3;
p_aout->l_rate = 48000;
}
if( p_aout->l_rate == 0 )
{
intf_ErrMsg( "aout error: null sample rate" );
......
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