[vlc-devel] [PATCH 06/17] aout: handle when the vlc_clock is reset

Thomas Guillem thomas at gllm.fr
Mon Feb 15 10:15:01 UTC 2021


Drop the audio block when the main clock is reset.
---
 src/audio_output/dec.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index 028044c25b4..3c7c261505d 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -266,6 +266,9 @@ static void aout_DecSilence (audio_output_t *aout, vlc_tick_t length, vlc_tick_t
     const vlc_tick_t system_pts =
        vlc_clock_ConvertToSystem(owner->sync.clock, system_now, pts,
                                  owner->sync.rate);
+    if (unlikely(system_pts == VLC_TICK_INVALID))
+        return;
+
     aout->play(aout, block, system_pts);
 }
 
@@ -308,6 +311,9 @@ static void aout_DecSynchronize(audio_output_t *aout, vlc_tick_t system_now,
         vlc_tick_t play_date =
             vlc_clock_ConvertToSystem(owner->sync.clock, system_now + delay,
                                       dec_pts, owner->sync.rate);
+        if (unlikely(play_date == VLC_TICK_INVALID))
+            return;
+
         vlc_tick_t jitter = play_date - system_now;
         if (jitter > 0)
         {
@@ -328,7 +334,8 @@ 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) || owner->bitexact)
+    if (unlikely(drift == INT64_MAX || drift == VLC_TICK_INVALID)
+     || owner->bitexact)
         return; /* cf. INT64_MAX comment in aout_DecPlay() */
 
     /* Following calculations expect an opposite drift. Indeed,
@@ -493,7 +500,9 @@ int aout_DecPlay(audio_output_t *aout, block_t *block)
     vlc_tick_t play_date =
         vlc_clock_ConvertToSystem(owner->sync.clock, system_now, original_pts,
                                   owner->sync.rate);
-    if (unlikely(play_date == INT64_MAX))
+    if (unlikely(play_date == VLC_TICK_INVALID))
+        goto drop;
+    else 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. */
-- 
2.30.0



More information about the vlc-devel mailing list