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

Add pause callback for audio output (aout_output_t.pf_pause)

This is required for PulseAudio synchronization and to pause/resume
with low-latency. This should also be useful for other buffered
 audio outputs such as ALSA or CoreAudio.
parent df08e998
......@@ -165,7 +165,8 @@ typedef struct aout_output_t
struct module_t * p_module;
struct aout_sys_t * p_sys;
void (* pf_play)( aout_instance_t * );
void (*pf_play)( aout_instance_t * );
void (* pf_pause)( aout_instance_t *, bool, mtime_t );
int (* pf_volume_set )( aout_instance_t *, audio_volume_t, bool );
int i_nb_samples;
} aout_output_t;
......
......@@ -366,6 +366,7 @@ static int Open (vlc_object_t *obj)
}
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = 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->output.output.i_rate = rate;
aout->output.pf_play = Play;
aout->output.pf_pause = NULL;
if (sys->set_volume != NULL)
aout->output.pf_volume_set = VolumeSet;
else
......
......@@ -123,6 +123,7 @@ static int Open ( vlc_object_t *p_this )
p_aout->output.output.i_rate = 44100;
p_aout->output.i_nb_samples = FRAME_SIZE;
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
msg_Dbg(p_aout, "Starting AudioQueue (status = %i)", status);
status = AudioQueueStart(p_sys->audioQueue, NULL);
......
......@@ -188,6 +188,7 @@ static int Open( vlc_object_t * p_this )
memset( p_sys->p_remainder_buffer, 0, sizeof(uint8_t) * BUFSIZE );
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
aout_FormatPrint( p_aout, "VLC is looking for:", (audio_sample_format_t *)&p_aout->output.output );
......
......@@ -174,6 +174,7 @@ static int OpenAudio( vlc_object_t *p_this )
p_aout->output.p_sys->b_playing = 0;
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
aout_VolumeSoftInit( p_aout );
/* Retrieve config values */
......
......@@ -163,6 +163,7 @@ static int Open( vlc_object_t * p_this )
}
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
/* Audio format */
psz_format = var_CreateGetString( p_this, "audiofile-format" );
......
......@@ -134,6 +134,7 @@ static int Open( vlc_object_t *p_this )
jack_set_graph_order_callback ( p_sys->p_jack_client, GraphChange, p_aout );
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
aout_VolumeSoftInit( p_aout );
/* JACK only supports fl32 format */
......
......@@ -260,6 +260,7 @@ static int Open( vlc_object_t * p_this )
p_aout->output.i_nb_samples = 2048;
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
aout_FormatPrepare( &p_aout->output.output );
......
......@@ -299,6 +299,7 @@ static int Open( vlc_object_t *p_this )
free( psz_device );
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
if ( var_Type( p_aout, "audio-device" ) == 0 )
{
......
......@@ -183,6 +183,7 @@ static int Open( vlc_object_t * p_this )
p_sys->p_stream = 0;
p_aout->output.p_sys = p_sys;
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
/* Retrieve output device id from config */
p_sys->i_device_id = var_CreateGetInteger( p_aout, "portaudio-audio-device" );
......
......@@ -581,6 +581,7 @@ static int Open(vlc_object_t *obj)
pa_threaded_mainloop_unlock(mainloop);
aout->output.pf_play = Play;
aout->output.pf_pause = NULL;
aout->output.pf_volume_set = VolumeSet;
return VLC_SUCCESS;
......
......@@ -215,6 +215,7 @@ static int Open ( vlc_object_t *p_this )
p_aout->output.output.i_rate = obtained.freq;
p_aout->output.i_nb_samples = obtained.samples;
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
return VLC_SUCCESS;
}
......
......@@ -154,8 +154,7 @@ static int Open( vlc_object_t *p_this )
return VLC_ENOMEM;
p_aout->output.pf_play = Play;
p_aout->b_die = false;
p_aout->output.pf_pause = NULL;
/*
initialize/update Device selection List
......
......@@ -51,6 +51,7 @@ int OpenAudio ( vlc_object_t * p_this )
aout_instance_t * p_aout = (aout_instance_t *)p_this;
p_aout->output.pf_play = Play;
p_aout->output.pf_pause = NULL;
aout_VolumeSoftInit( p_aout );
if( AOUT_FMT_NON_LINEAR( &p_aout->output.output )
......
......@@ -116,6 +116,7 @@ void aout_MixerRun( aout_instance_t * p_aout, float );
int aout_OutputNew( aout_instance_t * p_aout,
const audio_sample_format_t * p_format );
void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer );
void aout_OutputPause( aout_instance_t * p_aout, bool, mtime_t );
void aout_OutputDelete( aout_instance_t * p_aout );
......
......@@ -278,6 +278,7 @@ void aout_DecChangePause( aout_instance_t *p_aout, aout_input_t *p_input, bool b
}
aout_unlock_mixer( p_aout );
}
aout_OutputPause( p_aout, b_paused, i_date );
}
void aout_DecFlush( aout_instance_t *p_aout, aout_input_t *p_input )
......
......@@ -239,6 +239,19 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
aout_unlock_output_fifo( p_aout );
}
/**
* Notifies the audio output (if any) of pause/resume events.
* This enables the output to expedite pause, instead of waiting for its
* buffers to drain.
*/
void aout_OutputPause( aout_instance_t *aout, bool pause, mtime_t date )
{
aout_lock_output_fifo( aout );
if( aout->output.pf_pause != NULL )
aout->output.pf_pause( aout, pause, date );
aout_unlock_output_fifo( aout );
}
/*****************************************************************************
* aout_OutputNextBuffer : give the audio output plug-in the right buffer
*****************************************************************************
......
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