Commit f4bd2584 authored by Christophe Massiot's avatar Christophe Massiot

* Several stability patches for multiple input streams aout.

parent ef6c706b
......@@ -2,7 +2,7 @@
* spdif.c : dummy mixer for S/PDIF output (1 input only)
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: spdif.c,v 1.6 2002/09/20 23:27:03 massiot Exp $
* $Id: spdif.c,v 1.7 2002/09/28 13:05:16 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -73,8 +73,32 @@ static int Create( vlc_object_t *p_this )
*****************************************************************************/
static void DoWork( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
{
aout_input_t * p_input = p_aout->pp_inputs[0];
if ( p_input->b_error ) return;
int i = 0;
aout_input_t * p_input = p_aout->pp_inputs[i];
while ( p_input->b_error )
{
p_input = p_aout->pp_inputs[++i];
}
aout_FifoPop( p_aout, &p_input->fifo );
/* Empty other FIFOs to avoid a memory leak. */
for ( i++; i < p_aout->i_nb_inputs; i++ )
{
aout_fifo_t * p_fifo;
aout_buffer_t * p_deleted;
p_input = p_aout->pp_inputs[i];
if ( p_input->b_error ) continue;
p_fifo = &p_input->fifo;
p_deleted = p_fifo->p_first;
while ( p_deleted != NULL )
{
aout_buffer_t * p_next = p_deleted->p_next;
aout_BufferFree( p_deleted );
p_deleted = p_next;
}
p_fifo->p_first = NULL;
p_fifo->pp_last = &p_fifo->p_first;
}
}
......@@ -2,7 +2,7 @@
* trivial.c : trivial mixer plug-in (1 input, no downmixing)
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: trivial.c,v 1.7 2002/09/20 23:27:03 massiot Exp $
* $Id: trivial.c,v 1.8 2002/09/28 13:05:16 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -71,13 +71,21 @@ static int Create( vlc_object_t *p_this )
*****************************************************************************/
static void DoWork( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
{
aout_input_t * p_input = p_aout->pp_inputs[0];
int i = 0;
aout_input_t * p_input = p_aout->pp_inputs[i];
int i_nb_bytes = p_buffer->i_nb_samples * sizeof(s32)
* p_aout->mixer.mixer.i_channels;
byte_t * p_in = p_input->p_first_byte_to_mix;
byte_t * p_out = p_buffer->p_buffer;
byte_t * p_in;
byte_t * p_out;
if ( p_input->b_error ) return;
while ( p_input->b_error )
{
p_input = p_aout->pp_inputs[++i];
/* This can't crash because if no input has b_error == 0, the
* audio mixer cannot run and we can't be here. */
}
p_in = p_input->p_first_byte_to_mix;
p_out = p_buffer->p_buffer;
for ( ; ; )
{
......@@ -114,5 +122,25 @@ static void DoWork( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
break;
}
}
/* Empty other FIFOs to avoid a memory leak. */
for ( i++; i < p_aout->i_nb_inputs; i++ )
{
aout_fifo_t * p_fifo;
aout_buffer_t * p_deleted;
p_input = p_aout->pp_inputs[i];
if ( p_input->b_error ) continue;
p_fifo = &p_input->fifo;
p_deleted = p_fifo->p_first;
while ( p_deleted != NULL )
{
aout_buffer_t * p_next = p_deleted->p_next;
aout_BufferFree( p_deleted );
p_deleted = p_next;
}
p_fifo->p_first = NULL;
p_fifo->pp_last = &p_fifo->p_first;
}
}
......@@ -2,7 +2,7 @@
* decoder.c: AAC decoder using libfaad2
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: decoder.c,v 1.3 2002/09/26 22:40:21 massiot Exp $
* $Id: decoder.c,v 1.4 2002/09/28 13:05:16 massiot Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -329,6 +329,8 @@ static int InitThread( adec_thread_t * p_adec )
p_adec->output_format.i_format = AOUT_FMT_FLOAT32;
p_adec->output_format.i_rate = i_rate;
p_adec->output_format.i_channels = i_channels;
p_adec->p_aout = NULL;
p_adec->p_aout_input = NULL;
#if 0
if( !p_adec->format.p_data )
......
......@@ -2,7 +2,7 @@
* lpcm.c: lpcm decoder module
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: lpcm.c,v 1.2 2002/09/26 22:40:20 massiot Exp $
* $Id: lpcm.c,v 1.3 2002/09/28 13:05:16 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Henri Fallon <henri@videolan.org>
......@@ -131,6 +131,7 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
p_dec->output_format.i_rate = 48000;
aout_DateInit( &p_dec->end_date, 48000 );
p_dec->p_aout = NULL;
p_dec->p_aout_input = aout_DecNew( p_dec->p_fifo,
&p_dec->p_aout,
&p_dec->output_format );
......
......@@ -190,7 +190,7 @@ static void EndThread (mad_adec_thread_t * p_dec)
/* If the audio output fifo was created, we destroy it */
if (p_dec->p_aout_input != NULL)
{
aout_InputDelete( p_dec->p_aout, p_dec->p_aout_input );
aout_DecDelete( p_dec->p_aout, p_dec->p_aout_input );
}
/* mad_decoder_finish releases the memory allocated inside the struct */
......
......@@ -2,7 +2,7 @@
* mixer.c : audio output mixing operations
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: mixer.c,v 1.16 2002/09/26 22:40:25 massiot Exp $
* $Id: mixer.c,v 1.17 2002/09/28 13:05:16 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -74,7 +74,7 @@ int aout_MixerDelete( aout_instance_t * p_aout )
*****************************************************************************/
static int MixBuffer( aout_instance_t * p_aout )
{
int i, i_nb_real_inputs = 0;
int i, i_first_input = 0;
aout_buffer_t * p_output_buffer;
mtime_t start_date, end_date;
audio_date_t exact_start_date;
......@@ -168,8 +168,11 @@ static int MixBuffer( aout_instance_t * p_aout )
mtime_t prev_date;
vlc_bool_t b_drop_buffers;
if ( p_input->b_error ) continue;
i_nb_real_inputs++;
if ( p_input->b_error )
{
if ( i_first_input == i ) i_first_input++;
continue;
}
p_buffer = p_fifo->p_first;
if ( p_buffer == NULL )
......@@ -268,7 +271,7 @@ static int MixBuffer( aout_instance_t * p_aout )
if ( p_buffer == NULL ) break;
}
if ( i < p_aout->i_nb_inputs || !i_nb_real_inputs )
if ( i < p_aout->i_nb_inputs || i_first_input == p_aout->i_nb_inputs )
{
/* Interrupted before the end... We can't run. */
vlc_mutex_unlock( &p_aout->input_fifos_lock );
......@@ -281,7 +284,7 @@ static int MixBuffer( aout_instance_t * p_aout )
/ p_aout->output.output.i_rate,
/* This is a bit kludgy, but is actually only used
* for the S/PDIF dummy mixer : */
p_aout->pp_inputs[0]->fifo.p_first,
p_aout->pp_inputs[i_first_input]->fifo.p_first,
p_output_buffer );
if ( p_output_buffer == NULL )
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment