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

aout: always provide pause

parent f1dfd429
......@@ -195,7 +195,15 @@ struct audio_output
*/
void (*pause)( audio_output_t *, bool pause, mtime_t date);
/**< Pauses or resumes playback (optional, may be NULL).
/**< Pauses or resumes playback (mandatory, cannot be NULL).
*
* This callback pauses or resumes audio playback as quickly as possible.
* When pausing, it is desirable to stop producing sound immediately, but
* retain already queued audio samples in the buffer to play when later
* when resuming.
*
* If pausing is impossible, then aout_PauseDefault() can provide a
* fallback implementation of this callback.
*
* \param pause pause if true, resume from pause if false
* \param date timestamp when the pause or resume was requested
......@@ -436,6 +444,21 @@ static inline int aout_TimeGetDefault(audio_output_t *aout,
return -1;
}
/**
* Default implementation for audio_output_t.pause
*
* \warning This default callback implementation is suboptimal as it will
* discard some audio samples.
* Do not use this unless there are really no possible better alternatives.
*/
static inline void aout_PauseDefault(audio_output_t *aout, bool paused,
mtime_t date)
{
if (paused && aout->flush != NULL)
aout->flush(aout, false);
(void) date;
}
/* Audio output filters */
typedef struct
......
......@@ -180,7 +180,7 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
aout->time_get = TimeGet;
aout->play = Play;
aout->pause = NULL;
aout->pause = aout_PauseDefault;
aout->flush = Flush;
if (sio_onvol(sys->hdl, VolumeChanged, aout))
{
......
......@@ -1171,7 +1171,7 @@ static int OpenAudio(vlc_object_t *p_this)
aout->flush = Flush;
aout->time_get = TimeGet;
aout->pause = NULL;
aout->pause = aout_PauseDefault;
aout->stop = NULL;
aout->mute_set = NULL;
aout->volume_set= NULL;
......
......@@ -432,12 +432,7 @@ void aout_DecChangePause (audio_output_t *aout, bool paused, mtime_t date)
}
if (owner->mixer_format.i_format)
{
if (aout->pause != NULL)
aout->pause(aout, paused, date);
else if (paused)
aout->flush(aout, false);
}
aout->pause(aout, paused, date);
}
void aout_DecChangeRate(audio_output_t *aout, float rate)
......
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