* 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>
*
*****************************************************************************/
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;
+ }
}
* 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>
*
*****************************************************************************/
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 ( ; ; )
{
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;
+ }
}
* 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>
*
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 )
* 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>
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 );
/* 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 */
* 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>
*
*****************************************************************************/
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;
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 )
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 );
/ 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 )
{