[vlc-devel] [PATCH 2/6] aout: handle the case where the clock is paused

Thomas Guillem thomas at gllm.fr
Thu Sep 5 13:39:59 CEST 2019


This case can happen during a very short timespan, when the clock is paused
before the aout processed the pause event.
---
 src/audio_output/dec.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index e0c9f32b7e..05e3d355d7 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -307,6 +307,9 @@ void aout_RequestRetiming(audio_output_t *aout, vlc_tick_t system_ts,
     vlc_tick_t drift =
         -vlc_clock_Update(owner->sync.clock, system_ts, audio_ts, rate);
 
+    if (unlikely(drift == INT64_MAX))
+        return; /* cf. INT64_MAX comment in aout_DecPlay() */
+
     /* Late audio output.
      * This can happen due to insufficient caching, scheduling jitter
      * or bug in the decoder. Ideally, the output would seek backward. But that
@@ -456,9 +459,16 @@ int aout_DecPlay(audio_output_t *aout, block_t *block)
     vlc_tick_t system_now = vlc_tick_now();
     aout_DecSynchronize(aout, system_now, original_pts);
 
-    const vlc_tick_t play_date =
+    vlc_tick_t play_date =
         vlc_clock_ConvertToSystem(owner->sync.clock, system_now, original_pts,
                                   owner->sync.rate);
+    if (unlikely(play_date == INT64_MAX))
+    {
+        /* The clock is paused but not the output, play the audio anyway since
+         * we can't delay audio playback from here. */
+        play_date = system_now;
+
+    }
     /* Output */
     owner->sync.discontinuity = false;
     aout->play(aout, block, play_date);
-- 
2.20.1



More information about the vlc-devel mailing list