From 922ab4d4f4db117d9fd2862224899d659e2b2d8d Mon Sep 17 00:00:00 2001 From: Christophe Massiot Date: Mon, 19 Aug 2002 23:12:57 +0000 Subject: [PATCH] More changes in the date handling. Should be more tolerant with pause/play and change of audio channel. --- include/aout_internal.h | 33 +++--- modules/audio_output/file.c | 9 +- modules/misc/dummy/aout.c | 4 +- src/audio_output/audio_output.c | 7 +- src/audio_output/input.c | 43 +++----- src/audio_output/mixer.c | 173 ++++++++++++++++++-------------- src/audio_output/output.c | 17 ++-- 7 files changed, 147 insertions(+), 139 deletions(-) diff --git a/include/aout_internal.h b/include/aout_internal.h index 4d247cafd5..a6c93ecd2d 100644 --- a/include/aout_internal.h +++ b/include/aout_internal.h @@ -2,7 +2,7 @@ * aout_internal.h : internal defines for audio output ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: aout_internal.h,v 1.6 2002/08/19 21:31:11 massiot Exp $ + * $Id: aout_internal.h,v 1.7 2002/08/19 23:12:57 massiot Exp $ * * Authors: Christophe Massiot * @@ -82,7 +82,6 @@ typedef struct aout_alloc_t *****************************************************************************/ typedef struct aout_fifo_t { - vlc_mutex_t lock; struct aout_buffer_t * p_first; struct aout_buffer_t ** pp_last; mtime_t end_date; @@ -91,7 +90,6 @@ typedef struct aout_fifo_t static inline void aout_FifoInit( struct aout_instance_t * p_aout, aout_fifo_t * p_fifo ) { - vlc_mutex_init( (vlc_object_t *)p_aout, &p_fifo->lock ); p_fifo->p_first = NULL; p_fifo->pp_last = &p_fifo->p_first; p_fifo->end_date = 0; @@ -101,7 +99,6 @@ static inline void aout_FifoPush( struct aout_instance_t * p_aout, aout_fifo_t * p_fifo, aout_buffer_t * p_buffer ) { - vlc_mutex_lock( &p_fifo->lock ); *p_fifo->pp_last = p_buffer; p_fifo->pp_last = &p_buffer->p_next; *p_fifo->pp_last = NULL; @@ -118,26 +115,31 @@ static inline void aout_FifoPush( struct aout_instance_t * p_aout, { p_fifo->end_date = p_buffer->end_date; } - vlc_mutex_unlock( &p_fifo->lock ); } static inline mtime_t aout_FifoNextStart( struct aout_instance_t * p_aout, aout_fifo_t * p_fifo ) { - mtime_t end_date; - vlc_mutex_lock( &p_fifo->lock ); - end_date = p_fifo->end_date; - vlc_mutex_unlock( &p_fifo->lock ); - return end_date; + return p_fifo->end_date; } /* Reinit the end_date (for instance after a pause). */ static inline void aout_FifoSet( struct aout_instance_t * p_aout, aout_fifo_t * p_fifo, mtime_t date ) { - vlc_mutex_lock( &p_fifo->lock ); + aout_buffer_t * p_buffer; p_fifo->end_date = date; - vlc_mutex_unlock( &p_fifo->lock ); + + /* Remove all buffers. */ + p_buffer = p_fifo->p_first; + while ( p_buffer != NULL ) + { + aout_buffer_t * p_next = p_buffer->p_next; + aout_BufferFree( p_buffer ); + p_buffer = p_next; + } + p_fifo->p_first = NULL; + p_fifo->pp_last = &p_fifo->p_first; } /* This function supposes there is at least one buffer in p_fifo. */ @@ -145,14 +147,12 @@ static inline aout_buffer_t * aout_FifoPop( struct aout_instance_t * p_aout, aout_fifo_t * p_fifo ) { aout_buffer_t * p_buffer; - vlc_mutex_lock( &p_fifo->lock ); p_buffer = p_fifo->p_first; p_fifo->p_first = p_buffer->p_next; if ( p_fifo->p_first == NULL ) { p_fifo->pp_last = &p_fifo->p_first; } - vlc_mutex_unlock( &p_fifo->lock ); return p_buffer; } @@ -162,7 +162,6 @@ static inline void aout_FifoDestroy( struct aout_instance_t * p_aout, { aout_buffer_t * p_buffer; - vlc_mutex_destroy( &p_fifo->lock ); p_buffer = p_fifo->p_first; while ( p_buffer != NULL ) { @@ -260,9 +259,7 @@ struct aout_instance_t int i_nb_inputs; /* Mixer */ - vlc_cond_t mixer_signal; /* the associated mutex is - * p_aout->output.fifo.lock */ - vlc_bool_t b_mixer_active; + vlc_mutex_t mixer_lock; aout_mixer_t mixer; /* Output plug-in */ diff --git a/modules/audio_output/file.c b/modules/audio_output/file.c index cd5ddfbb06..ba86ad2183 100644 --- a/modules/audio_output/file.c +++ b/modules/audio_output/file.c @@ -2,7 +2,7 @@ * file.c : audio output which writes the samples to a file ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: file.c,v 1.7 2002/08/19 23:07:30 sam Exp $ + * $Id: file.c,v 1.8 2002/08/19 23:12:57 massiot Exp $ * * Authors: Christophe Massiot * @@ -148,7 +148,12 @@ static int SetFormat( aout_instance_t * p_aout ) *****************************************************************************/ static void Play( aout_instance_t * p_aout ) { - aout_buffer_t * p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo ); + aout_buffer_t * p_buffer; + + /* We don't need the mixer lock, since Play is entered _with_ the + * mixer lock. */ + p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo ); + if( fwrite( p_buffer->p_buffer, p_buffer->i_nb_bytes, 1, (FILE *)p_aout->output.p_sys ) != 1 ) { diff --git a/modules/misc/dummy/aout.c b/modules/misc/dummy/aout.c index 379924773f..e9c7246a45 100644 --- a/modules/misc/dummy/aout.c +++ b/modules/misc/dummy/aout.c @@ -2,7 +2,7 @@ * aout_dummy.c : dummy audio output plugin ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: aout.c,v 1.5 2002/08/19 21:31:11 massiot Exp $ + * $Id: aout.c,v 1.6 2002/08/19 23:12:57 massiot Exp $ * * Authors: Christophe Massiot * @@ -77,6 +77,8 @@ static int SetFormat( aout_instance_t * p_aout ) *****************************************************************************/ static void Play( aout_instance_t * p_aout ) { + /* We don't need the mixer lock, since Play is entered _with_ the + * mixer lock. */ aout_buffer_t * p_buffer = aout_FifoPop( p_aout, &p_aout->output.fifo ); aout_BufferFree( p_buffer ); } diff --git a/src/audio_output/audio_output.c b/src/audio_output/audio_output.c index 28205ead73..c9813d4895 100644 --- a/src/audio_output/audio_output.c +++ b/src/audio_output/audio_output.c @@ -2,7 +2,7 @@ * audio_output.c : audio output instance ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: audio_output.c,v 1.97 2002/08/19 21:31:11 massiot Exp $ + * $Id: audio_output.c,v 1.98 2002/08/19 23:12:57 massiot Exp $ * * Authors: Christophe Massiot * @@ -57,8 +57,7 @@ aout_instance_t * __aout_NewInstance( vlc_object_t * p_parent ) p_aout->b_change_requested = 0; p_aout->i_nb_inputs = 0; - vlc_cond_init( p_parent, &p_aout->mixer_signal ); - p_aout->b_mixer_active = 0; + vlc_mutex_init( p_parent, &p_aout->mixer_lock ); vlc_object_attach( p_aout, p_parent->p_vlc ); @@ -72,7 +71,7 @@ void aout_DeleteInstance( aout_instance_t * p_aout ) { vlc_mutex_destroy( &p_aout->input_lock ); vlc_cond_destroy( &p_aout->input_signal ); - vlc_cond_destroy( &p_aout->mixer_signal ); + vlc_mutex_destroy( &p_aout->mixer_lock ); /* Free structure. */ vlc_object_destroy( p_aout ); diff --git a/src/audio_output/input.c b/src/audio_output/input.c index 33621f2481..0e0b9cbdf3 100644 --- a/src/audio_output/input.c +++ b/src/audio_output/input.c @@ -2,7 +2,7 @@ * input.c : internal management of input streams for the audio output ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: input.c,v 1.5 2002/08/19 21:31:11 massiot Exp $ + * $Id: input.c,v 1.6 2002/08/19 23:12:57 massiot Exp $ * * Authors: Christophe Massiot * @@ -42,13 +42,7 @@ static aout_input_t * InputNew( aout_instance_t * p_aout, if ( p_input == NULL ) return NULL; - vlc_mutex_lock( &p_aout->output.fifo.lock ); - while ( p_aout->b_mixer_active ) - { - vlc_cond_wait( &p_aout->mixer_signal, &p_aout->output.fifo.lock ); - } - p_aout->b_mixer_active = 1; - vlc_mutex_unlock( &p_aout->output.fifo.lock ); + vlc_mutex_lock( &p_aout->mixer_lock ); if ( p_aout->i_nb_inputs == 0 ) { @@ -110,18 +104,12 @@ static aout_input_t * InputNew( aout_instance_t * p_aout, { aout_MixerNew( p_aout ); } - vlc_mutex_lock( &p_aout->output.fifo.lock ); - p_aout->b_mixer_active = 0; - vlc_cond_signal( &p_aout->mixer_signal ); - vlc_mutex_unlock( &p_aout->output.fifo.lock ); + vlc_mutex_unlock( &p_aout->mixer_lock ); return NULL; } - vlc_mutex_lock( &p_aout->output.fifo.lock ); - p_aout->b_mixer_active = 0; - vlc_cond_signal( &p_aout->mixer_signal ); - vlc_mutex_unlock( &p_aout->output.fifo.lock ); + vlc_mutex_unlock( &p_aout->mixer_lock ); /* Prepare hints for the buffer allocator. */ p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP; @@ -177,15 +165,7 @@ void aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input ) { int i_input; - msg_Dbg( p_aout, "input 0x%x destroyed", p_input ); - - vlc_mutex_lock( &p_aout->output.fifo.lock ); - while ( p_aout->b_mixer_active ) - { - vlc_cond_wait( &p_aout->mixer_signal, &p_aout->output.fifo.lock ); - } - p_aout->b_mixer_active = 1; - vlc_mutex_unlock( &p_aout->output.fifo.lock ); + vlc_mutex_lock( &p_aout->mixer_lock ); for ( i_input = 0; i_input < p_aout->i_nb_inputs; i_input++ ) { @@ -206,10 +186,7 @@ void aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input ) (AOUT_MAX_INPUTS - i_input - 1) * sizeof(aout_input_t *) ); p_aout->i_nb_inputs--; - vlc_mutex_lock( &p_aout->output.fifo.lock ); - p_aout->b_mixer_active = 0; - vlc_cond_signal( &p_aout->mixer_signal ); - vlc_mutex_unlock( &p_aout->output.fifo.lock ); + vlc_mutex_unlock( &p_aout->mixer_lock ); aout_FiltersDestroyPipeline( p_aout, p_input->pp_filters, p_input->i_nb_filters ); @@ -222,6 +199,8 @@ void aout_InputDelete( aout_instance_t * p_aout, aout_input_t * p_input ) aout_OutputDelete( p_aout ); aout_MixerDelete( p_aout ); } + + msg_Dbg( p_aout, "input 0x%x destroyed", p_input ); } /***************************************************************************** @@ -252,7 +231,9 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, * happen :). */ msg_Warn( p_aout, "Computed PTS is out of range (%lld), clearing out", start_date ); + vlc_mutex_lock( &p_aout->mixer_lock ); aout_FifoSet( p_aout, &p_input->fifo, 0 ); + vlc_mutex_unlock( &p_aout->mixer_lock ); start_date = 0; } @@ -314,7 +295,9 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, &new_output ) < 0 ) { msg_Err( p_aout, "couldn't set an input pipeline for resampling" ); + vlc_mutex_lock( &p_aout->mixer_lock ); aout_FifoSet( p_aout, &p_input->fifo, 0 ); + vlc_mutex_unlock( &p_aout->mixer_lock ); aout_BufferFree( p_buffer ); vlc_mutex_lock( &p_aout->input_lock ); @@ -347,7 +330,9 @@ void aout_InputPlay( aout_instance_t * p_aout, aout_input_t * p_input, /* Adding the start date will be managed by aout_FifoPush(). */ p_buffer->start_date = start_date; p_buffer->end_date = start_date + duration; + vlc_mutex_lock( &p_aout->mixer_lock ); aout_FifoPush( p_aout, &p_input->fifo, p_buffer ); + vlc_mutex_unlock( &p_aout->mixer_lock ); vlc_mutex_lock( &p_aout->input_lock ); p_aout->i_inputs_active--; diff --git a/src/audio_output/mixer.c b/src/audio_output/mixer.c index 1b6f261aa0..c4d5437d9d 100644 --- a/src/audio_output/mixer.c +++ b/src/audio_output/mixer.c @@ -2,7 +2,7 @@ * mixer.c : audio output mixing operations ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: mixer.c,v 1.7 2002/08/19 21:54:37 massiot Exp $ + * $Id: mixer.c,v 1.8 2002/08/19 23:12:57 massiot Exp $ * * Authors: Christophe Massiot * @@ -59,19 +59,17 @@ void aout_MixerDelete( aout_instance_t * p_aout ) } /***************************************************************************** - * aout_MixerRun: entry point for the mixer & post-filters processing + * MixBuffer: try to prepare one output buffer *****************************************************************************/ -void aout_MixerRun( aout_instance_t * p_aout ) +static int MixBuffer( aout_instance_t * p_aout ) { int i; aout_buffer_t * p_output_buffer; mtime_t start_date, end_date; - /* Retrieve the date of the next buffer. We don't use aout_FifoNextStart - * because we need to keep the lock on the FIFO, to prevent the aout - * thread from triggering resampling while we are running. */ - vlc_mutex_lock( &p_aout->output.fifo.lock ); - start_date = p_aout->output.fifo.end_date; + /* Retrieve the date of the next buffer. */ + vlc_mutex_lock( &p_aout->mixer_lock ); + start_date = aout_FifoNextStart( p_aout, &p_aout->output.fifo ); if ( start_date != 0 && start_date < mdate() ) { /* The output is _very_ late. This can only happen if the user @@ -81,11 +79,42 @@ void aout_MixerRun( aout_instance_t * p_aout ) start_date ); start_date = p_aout->output.fifo.end_date = 0; } + + /* See if we have enough data to prepare a new buffer for the audio + * output. First : start date. */ + if ( !start_date ) + { + /* Find the latest start date available. */ + for ( i = 0; i < p_aout->i_nb_inputs; i++ ) + { + aout_input_t * p_input = p_aout->pp_inputs[i]; + aout_fifo_t * p_fifo = &p_input->fifo; + aout_buffer_t * p_buffer; + + p_buffer = p_fifo->p_first; + if ( p_buffer == NULL ) + { + break; + } + + if ( !start_date || start_date < p_buffer->start_date ) + { + start_date = p_buffer->start_date; + } + } + + if ( i < p_aout->i_nb_inputs ) + { + /* Interrupted before the end... We can't run. */ + vlc_mutex_unlock( &p_aout->mixer_lock ); + return -1; + } + } end_date = start_date + (mtime_t)p_aout->output.i_nb_samples * 1000000 / p_aout->output.output.i_rate; - /* See if we have enough data to prepare a new buffer for the audio - * output. */ + /* Check that start_date and end_date are available for all input + * streams. */ for ( i = 0; i < p_aout->i_nb_inputs; i++ ) { aout_input_t * p_input = p_aout->pp_inputs[i]; @@ -94,73 +123,60 @@ void aout_MixerRun( aout_instance_t * p_aout ) mtime_t prev_date; vlc_bool_t b_drop_buffers; - vlc_mutex_lock( &p_fifo->lock ); - p_buffer = p_fifo->p_first; if ( p_buffer == NULL ) { - vlc_mutex_unlock( &p_fifo->lock ); break; } - if ( !start_date ) + /* Check for the continuity of start_date */ + while ( p_buffer != NULL && p_buffer->end_date < start_date ) { - start_date = p_buffer->start_date; - end_date += p_buffer->start_date; - p_input->p_first_byte_to_mix = p_buffer->p_buffer; + aout_buffer_t * p_next = p_buffer->p_next; + msg_Err( p_aout, "the mixer got a packet in the past (%lld)", + start_date - p_buffer->end_date ); + aout_BufferFree( p_buffer ); + p_fifo->p_first = p_buffer = p_next; + p_input->p_first_byte_to_mix = NULL; } - else + if ( p_buffer == NULL ) { - /* Check for the continuity of start_date */ - while ( p_buffer != NULL && p_buffer->end_date < start_date ) - { - aout_buffer_t * p_next = p_buffer->p_next; - msg_Err( p_aout, "the mixer got a packet in the past (%lld)", - start_date - p_buffer->end_date ); - aout_BufferFree( p_buffer ); - p_fifo->p_first = p_buffer = p_next; - p_input->p_first_byte_to_mix = NULL; - } - if ( p_buffer == NULL ) + p_fifo->pp_last = &p_fifo->p_first; + break; + } + + if ( !AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) ) + { + /* Additionally check that p_first_byte_to_mix is well + * located. */ + unsigned long i_nb_bytes = (start_date - p_buffer->start_date) + * p_aout->mixer.mixer.i_bytes_per_frame + * p_aout->mixer.mixer.i_rate + / p_aout->mixer.mixer.i_frame_length + / 1000000; + ptrdiff_t mixer_nb_bytes; + + if ( p_input->p_first_byte_to_mix == NULL ) { - p_fifo->pp_last = &p_fifo->p_first; - vlc_mutex_unlock( &p_fifo->lock ); - break; + p_input->p_first_byte_to_mix = p_buffer->p_buffer; } + mixer_nb_bytes = p_input->p_first_byte_to_mix + - p_buffer->p_buffer; - if ( !AOUT_FMT_NON_LINEAR( &p_aout->mixer.mixer ) ) + if ( i_nb_bytes + p_aout->mixer.mixer.i_bytes_per_frame + < mixer_nb_bytes || + i_nb_bytes - p_aout->mixer.mixer.i_bytes_per_frame + > mixer_nb_bytes ) { - /* Additionally check that p_first_byte_to_mix is well - * located. */ - unsigned long i_nb_bytes = (start_date - p_buffer->start_date) - * p_aout->mixer.mixer.i_bytes_per_frame - * p_aout->mixer.mixer.i_rate - / p_aout->mixer.mixer.i_frame_length - / 1000000; - ptrdiff_t mixer_nb_bytes; - - if ( p_input->p_first_byte_to_mix == NULL ) - { - p_input->p_first_byte_to_mix = p_buffer->p_buffer; - } - mixer_nb_bytes = p_input->p_first_byte_to_mix - - p_buffer->p_buffer; + msg_Warn( p_aout, + "mixer start isn't output start (%ld)", + i_nb_bytes - mixer_nb_bytes ); - if ( i_nb_bytes + p_aout->mixer.mixer.i_bytes_per_frame - < mixer_nb_bytes || - i_nb_bytes - p_aout->mixer.mixer.i_bytes_per_frame - > mixer_nb_bytes ) - { - msg_Warn( p_aout, - "mixer start isn't output start (%ld)", - i_nb_bytes - mixer_nb_bytes ); - - /* Round to the nearest multiple */ - i_nb_bytes /= p_aout->mixer.mixer.i_bytes_per_frame; - i_nb_bytes *= p_aout->mixer.mixer.i_bytes_per_frame; - p_input->p_first_byte_to_mix = p_buffer->p_buffer - + i_nb_bytes; - } + /* Round to the nearest multiple */ + i_nb_bytes /= p_aout->mixer.mixer.i_bytes_per_frame; + i_nb_bytes *= p_aout->mixer.mixer.i_bytes_per_frame; + p_input->p_first_byte_to_mix = p_buffer->p_buffer + + i_nb_bytes; } } @@ -180,7 +196,7 @@ void aout_MixerRun( aout_instance_t * p_aout ) if ( prev_date != p_buffer->start_date ) { msg_Warn( p_aout, - "buffer discontinuity, dropping packets (%lld)", + "buffer hole, dropping packets (%lld)", p_buffer->start_date - prev_date ); b_drop_buffers = 1; break; @@ -201,20 +217,16 @@ void aout_MixerRun( aout_instance_t * p_aout ) } else break; } - vlc_mutex_unlock( &p_fifo->lock ); if ( p_buffer == NULL ) break; } if ( i < p_aout->i_nb_inputs ) { /* Interrupted before the end... We can't run. */ - vlc_mutex_unlock( &p_aout->output.fifo.lock ); - return; + vlc_mutex_unlock( &p_aout->mixer_lock ); + return -1; } - p_aout->b_mixer_active = 1; - vlc_mutex_unlock( &p_aout->output.fifo.lock ); - /* Run the mixer. */ aout_BufferAlloc( &p_aout->mixer.output_alloc, ((u64)p_aout->output.i_nb_samples * 1000000) @@ -226,22 +238,29 @@ void aout_MixerRun( aout_instance_t * p_aout ) if ( p_output_buffer == NULL ) { msg_Err( p_aout, "out of memory" ); - return; + vlc_mutex_unlock( &p_aout->mixer_lock ); + return -1; } p_output_buffer->i_nb_samples = p_aout->output.i_nb_samples; p_output_buffer->i_nb_bytes = p_aout->output.i_nb_samples - * p_aout->output.output.i_bytes_per_frame - / p_aout->output.output.i_frame_length; + * p_aout->mixer.mixer.i_bytes_per_frame + / p_aout->mixer.mixer.i_frame_length; p_output_buffer->start_date = start_date; p_output_buffer->end_date = end_date; p_aout->mixer.pf_do_work( p_aout, p_output_buffer ); + vlc_mutex_unlock( &p_aout->mixer_lock ); + aout_OutputPlay( p_aout, p_output_buffer ); - vlc_mutex_lock( &p_aout->output.fifo.lock ); - p_aout->b_mixer_active = 0; - vlc_cond_signal( &p_aout->mixer_signal ); - vlc_mutex_unlock( &p_aout->output.fifo.lock ); + return 0; } +/***************************************************************************** + * aout_MixerRun: entry point for the mixer & post-filters processing + *****************************************************************************/ +void aout_MixerRun( aout_instance_t * p_aout ) +{ + while( MixBuffer( p_aout ) != -1 ); +} diff --git a/src/audio_output/output.c b/src/audio_output/output.c index b33a60adfe..fa1cb4a4d9 100644 --- a/src/audio_output/output.c +++ b/src/audio_output/output.c @@ -2,7 +2,7 @@ * output.c : internal management of output streams for the audio output ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: output.c,v 1.7 2002/08/19 21:31:11 massiot Exp $ + * $Id: output.c,v 1.8 2002/08/19 23:12:57 massiot Exp $ * * Authors: Christophe Massiot * @@ -43,9 +43,7 @@ int aout_OutputNew( aout_instance_t * p_aout, int i_channels = config_GetInt( p_aout, "aout-channels" ); /* Prepare FIFO. */ - vlc_mutex_init( p_aout, &p_aout->output.fifo.lock ); - p_aout->output.fifo.p_first = NULL; - p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first; + aout_FifoInit( p_aout, &p_aout->output.fifo ); p_aout->output.p_module = module_Need( p_aout, "audio output", psz_name ); @@ -151,6 +149,7 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer ) p_aout->output.i_nb_filters, &p_buffer ); + /* Please remember that we have the mixer_lock in this function. */ aout_FifoPush( p_aout, &p_aout->output.fifo, p_buffer ); p_aout->output.pf_play( p_aout ); @@ -169,7 +168,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, { aout_buffer_t * p_buffer; - vlc_mutex_lock( &p_aout->output.fifo.lock ); + vlc_mutex_lock( &p_aout->mixer_lock ); p_buffer = p_aout->output.fifo.p_first; while ( p_buffer != NULL && p_buffer->end_date < start_date ) @@ -183,7 +182,9 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, if ( p_buffer == NULL ) { p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first; - vlc_mutex_unlock( &p_aout->output.fifo.lock ); + /* Set date to 0, to allow the mixer to send a new buffer ASAP */ + p_aout->output.fifo.end_date = 0; + vlc_mutex_unlock( &p_aout->mixer_lock ); msg_Dbg( p_aout, "audio output is starving" ); return NULL; } @@ -193,7 +194,7 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, if ( p_buffer->start_date > start_date + (p_buffer->end_date - p_buffer->start_date) ) { - vlc_mutex_unlock( &p_aout->output.fifo.lock ); + vlc_mutex_unlock( &p_aout->mixer_lock ); msg_Dbg( p_aout, "audio output is starving (%lld)", p_buffer->start_date - start_date ); return NULL; @@ -222,6 +223,6 @@ aout_buffer_t * aout_OutputNextBuffer( aout_instance_t * p_aout, p_aout->output.fifo.pp_last = &p_aout->output.fifo.p_first; } - vlc_mutex_unlock( &p_aout->output.fifo.lock ); + vlc_mutex_unlock( &p_aout->mixer_lock ); return p_buffer; } -- 2.39.5