[vlc-devel] [RFC PATCH 1/9] aout: reorder
Thomas Guillem
thomas at gllm.fr
Thu Dec 10 18:10:07 CET 2020
No functional changes.
---
src/audio_output/dec.c | 104 ++++++++++++++++++++---------------------
1 file changed, 51 insertions(+), 53 deletions(-)
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 028044c25b..f95ec3c299 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -242,8 +242,6 @@ static void aout_StopResampling (audio_output_t *aout)
aout_FiltersAdjustResampling (owner->filters, 0);
}
-static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t system_now,
- vlc_tick_t dec_pts);
static void aout_DecSilence (audio_output_t *aout, vlc_tick_t length, vlc_tick_t pts)
{
aout_owner_t *owner = aout_owner (aout);
@@ -269,57 +267,6 @@ static void aout_DecSilence (audio_output_t *aout, vlc_tick_t length, vlc_tick_t
aout->play(aout, block, system_pts);
}
-static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t system_now,
- vlc_tick_t dec_pts)
-{
- /**
- * Depending on the drift between the actual and intended playback times,
- * the audio core may ignore the drift, trigger upsampling or downsampling,
- * insert silence or even discard samples.
- * Future VLC versions may instead adjust the input rate.
- *
- * The audio output plugin is responsible for estimating its actual
- * playback time, or rather the estimated time when the next sample will
- * be played. (The actual playback time is always the current time, that is
- * to say vlc_tick_now(). It is not an useful statistic.)
- *
- * Most audio output plugins can estimate the delay until playback of
- * the next sample to be written to the buffer, or equally the time until
- * all samples in the buffer will have been played. Then:
- * pts = vlc_tick_now() + delay
- */
- aout_owner_t *owner = aout_owner (aout);
- vlc_tick_t delay;
-
- if (aout_TimeGet(aout, &delay) != 0)
- return; /* nothing can be done if timing is unknown */
-
- if (owner->sync.discontinuity)
- {
- /* Chicken-egg situation for most aout modules that can't be started
- * deferred (all except PulseAudio). These modules will start to play
- * data immediately and ignore the given play_date (that take the clock
- * jitter into account). We don't want to let aout_RequestRetiming()
- * handle the first silence (from the "Early audio output" case) since
- * this function will first update the clock without taking the jitter
- * into account. Therefore, we manually insert silence that correspond
- * to the clock jitter value before updating the clock.
- */
- vlc_tick_t play_date =
- vlc_clock_ConvertToSystem(owner->sync.clock, system_now + delay,
- dec_pts, owner->sync.rate);
- vlc_tick_t jitter = play_date - system_now;
- if (jitter > 0)
- {
- aout_DecSilence (aout, jitter, dec_pts - delay);
- if (aout_TimeGet(aout, &delay) != 0)
- return;
- }
- }
-
- aout_RequestRetiming(aout, system_now + delay, dec_pts);
-}
-
void aout_RequestRetiming(audio_output_t *aout, vlc_tick_t system_ts,
vlc_tick_t audio_ts)
{
@@ -423,6 +370,57 @@ void aout_RequestRetiming(audio_output_t *aout, vlc_tick_t system_ts,
}
}
+static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t system_now,
+ vlc_tick_t dec_pts)
+{
+ /**
+ * Depending on the drift between the actual and intended playback times,
+ * the audio core may ignore the drift, trigger upsampling or downsampling,
+ * insert silence or even discard samples.
+ * Future VLC versions may instead adjust the input rate.
+ *
+ * The audio output plugin is responsible for estimating its actual
+ * playback time, or rather the estimated time when the next sample will
+ * be played. (The actual playback time is always the current time, that is
+ * to say vlc_tick_now(). It is not an useful statistic.)
+ *
+ * Most audio output plugins can estimate the delay until playback of
+ * the next sample to be written to the buffer, or equally the time until
+ * all samples in the buffer will have been played. Then:
+ * pts = vlc_tick_now() + delay
+ */
+ aout_owner_t *owner = aout_owner (aout);
+ vlc_tick_t delay;
+
+ if (aout_TimeGet(aout, &delay) != 0)
+ return; /* nothing can be done if timing is unknown */
+
+ if (owner->sync.discontinuity)
+ {
+ /* Chicken-egg situation for most aout modules that can't be started
+ * deferred (all except PulseAudio). These modules will start to play
+ * data immediately and ignore the given play_date (that take the clock
+ * jitter into account). We don't want to let aout_RequestRetiming()
+ * handle the first silence (from the "Early audio output" case) since
+ * this function will first update the clock without taking the jitter
+ * into account. Therefore, we manually insert silence that correspond
+ * to the clock jitter value before updating the clock.
+ */
+ vlc_tick_t play_date =
+ vlc_clock_ConvertToSystem(owner->sync.clock, system_now + delay,
+ dec_pts, owner->sync.rate);
+ vlc_tick_t jitter = play_date - system_now;
+ if (jitter > 0)
+ {
+ aout_DecSilence (aout, jitter, dec_pts - delay);
+ if (aout_TimeGet(aout, &delay) != 0)
+ return;
+ }
+ }
+
+ aout_RequestRetiming(aout, system_now + delay, dec_pts);
+}
+
/*****************************************************************************
* aout_DecPlay : filter & mix the decoded buffer
*****************************************************************************/
--
2.29.2
More information about the vlc-devel
mailing list