From 1ae26b6c257e4e8ffa800a41b3289076240bf8f8 Mon Sep 17 00:00:00 2001
From: Thomas Guillem <thomas@gllm.fr>
Date: Tue, 24 Jul 2018 18:28:28 +0200
Subject: [PATCH] audiounit_ios: fix resume from pause

Fixes #20885
---
 modules/audio_output/audiounit_ios.m | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
index aca7c44de8f3..e449f6e2eb0c 100644
--- a/modules/audio_output/audiounit_ios.m
+++ b/modules/audio_output/audiounit_ios.m
@@ -402,6 +402,14 @@ Pause (audio_output_t *p_aout, bool pause, vlc_tick_t date)
     }
     p_sys->b_stopped = pause;
     ca_Pause(p_aout, pause, date);
+
+    /* Since we stopped the AudioUnit, we can't really recover the delay from
+     * the last playback. So it's better to flush everything now to avoid
+     * synchronization glitches when resuming from pause. The main drawback is
+     * that we loose 1-2 sec of audio when resuming. The order is important
+     * here, ca_Flush need to be called when paused. */
+    if (pause)
+        ca_Flush(p_aout, false);
 }
 
 static void
-- 
GitLab