Commit cba93daf authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: add an optional flush/drain callback

Audio output plugins can use this to expedite discarding pending
buffers. This reduces latency upon seeking or stopping the input.

This new callback also supports explicit draining, but this is not
used for the time being.
parent ed6c90b3
......@@ -203,6 +203,8 @@ struct audio_output
void (*pf_play)( audio_output_t * ); /**< Audio buffer callback */
void (* pf_pause)( audio_output_t *, bool, mtime_t ); /**< Pause/resume
callback (optional, may be NULL) */
void (* pf_flush)( audio_output_t *, bool ); /**< Flush/drain callback
(optional, may be NULL) */
aout_volume_cb pf_volume_set; /**< Volume setter (or NULL) */
int i_nb_samples;
};
......
......@@ -369,6 +369,7 @@ static int Open (vlc_object_t *obj)
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
snd_pcm_hw_params_t *p_hw;
snd_pcm_sw_params_t *p_sw;
......
......@@ -132,6 +132,7 @@ static int Open (vlc_object_t *obj)
aout->pf_play = Play;
aout->pf_pause = NULL;
aout->pf_flush = NULL;
if (sys->set_volume != NULL)
aout->pf_volume_set = VolumeSet;
else
......
......@@ -124,6 +124,7 @@ static int Open ( vlc_object_t *p_this )
p_aout->format.i_nb_samples = FRAME_SIZE;
p_aout->format.pf_play = Play;
p_aout->format.pf_pause = NULL;
p_aout->pf_flush = NULL;
msg_Dbg(p_aout, "Starting AudioQueue (status = %i)", status);
status = AudioQueueStart(p_sys->audioQueue, NULL);
......
......@@ -189,6 +189,7 @@ static int Open( vlc_object_t * p_this )
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
aout_FormatPrint( p_aout, "VLC is looking for:", &p_aout->format );
......
......@@ -175,6 +175,7 @@ static int OpenAudio( vlc_object_t *p_this )
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
aout_VolumeSoftInit( p_aout );
/* Retrieve config values */
......
......@@ -164,6 +164,7 @@ static int Open( vlc_object_t * p_this )
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
/* Audio format */
psz_format = var_CreateGetString( p_this, "audiofile-format" );
......
......@@ -135,6 +135,7 @@ static int Open( vlc_object_t *p_this )
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
aout_VolumeSoftInit( p_aout );
/* JACK only supports fl32 format */
......
......@@ -260,7 +260,8 @@ static int Open( vlc_object_t * p_this )
p_aout->i_nb_samples = 2048;
p_aout->format.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
aout_FormatPrepare( &p_aout->format );
......
......@@ -300,6 +300,7 @@ static int Open( vlc_object_t *p_this )
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
if ( var_Type( p_aout, "audio-device" ) == 0 )
{
......
......@@ -184,6 +184,7 @@ static int Open( vlc_object_t * p_this )
p_aout->sys = p_sys;
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
/* Retrieve output device id from config */
p_sys->i_device_id = var_CreateGetInteger( p_aout, "portaudio-audio-device" );
......
......@@ -783,6 +783,7 @@ static int Open(vlc_object_t *obj)
aout->format.i_format = format;
aout->pf_play = Play;
aout->pf_pause = Pause;
aout->pf_flush = NULL;
aout->pf_volume_set = VolumeSet;
return VLC_SUCCESS;
......
......@@ -216,6 +216,7 @@ static int Open ( vlc_object_t *p_this )
p_aout->i_nb_samples = obtained.samples;
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
return VLC_SUCCESS;
}
......
......@@ -156,6 +156,7 @@ static int Open( vlc_object_t *p_this )
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
/*
initialize/update Device selection List
......
......@@ -52,6 +52,7 @@ int OpenAudio ( vlc_object_t * p_this )
p_aout->pf_play = Play;
p_aout->pf_pause = NULL;
p_aout->pf_flush = NULL;
aout_VolumeSoftInit( p_aout );
if( AOUT_FMT_NON_LINEAR( &p_aout->format )
......
......@@ -123,6 +123,7 @@ int aout_OutputNew( audio_output_t * p_aout,
const audio_sample_format_t * p_format );
void aout_OutputPlay( audio_output_t * p_aout, aout_buffer_t * p_buffer );
void aout_OutputPause( audio_output_t * p_aout, bool, mtime_t );
void aout_OutputFlush( audio_output_t * p_aout, bool );
void aout_OutputDelete( audio_output_t * p_aout );
......
......@@ -242,6 +242,8 @@ void aout_DecFlush( audio_output_t *p_aout, aout_input_t *p_input )
{
aout_lock( p_aout );
aout_FifoReset( &p_input->fifo );
aout_FifoReset( &p_aout->fifo );
aout_OutputFlush( p_aout, false );
aout_unlock( p_aout );
}
......
......@@ -252,6 +252,20 @@ void aout_OutputPause( audio_output_t *aout, bool pause, mtime_t date )
aout->pf_pause( aout, pause, date );
}
/**
* Flushes or drains the audio output buffers.
* This enables the output to expedite seek and stop.
* @param wait if true, wait for buffer playback (i.e. drain),
* if false, discard the buffers immediately (i.e. flush)
*/
void aout_OutputFlush( audio_output_t *aout, bool wait )
{
vlc_assert_locked( &aout->lock );
if( aout->pf_flush != NULL )
aout->pf_flush( aout, wait );
}
/*** Volume handling ***/
......
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