[vlc-commits] aout: always provide pause
Rémi Denis-Courmont
git at videolan.org
Sat May 5 17:46:04 CEST 2018
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat May 5 17:43:02 2018 +0300| [5476c7280dfb70a62b24786bccbc9cb781fba107] | committer: Rémi Denis-Courmont
aout: always provide pause
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5476c7280dfb70a62b24786bccbc9cb781fba107
---
include/vlc_aout.h | 25 ++++++++++++++++++++++++-
modules/audio_output/sndio.c | 2 +-
modules/video_output/decklink.cpp | 2 +-
src/audio_output/dec.c | 7 +------
4 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 9363532dc9..f03b26d4fb 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -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
diff --git a/modules/audio_output/sndio.c b/modules/audio_output/sndio.c
index c240f505c4..fedcda53ad 100644
--- a/modules/audio_output/sndio.c
+++ b/modules/audio_output/sndio.c
@@ -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))
{
diff --git a/modules/video_output/decklink.cpp b/modules/video_output/decklink.cpp
index d4cb4aef9f..3d785b9cf8 100644
--- a/modules/video_output/decklink.cpp
+++ b/modules/video_output/decklink.cpp
@@ -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;
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 1bd7b86dde..28d726f1ba 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -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)
More information about the vlc-commits
mailing list