[vlc-commits] coreaudio: fix first time_get return values

Thomas Guillem git at videolan.org
Tue Jul 16 12:09:22 CEST 2019


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jul 15 16:58:22 2019 +0200| [704bd1291f203684cb5b87841697a4f68714dea6] | committer: Thomas Guillem

coreaudio: fix first time_get return values

Don't return a valid delay of 0 when the delay is still not known.

This triggered VLC drift correction from aout_DecSynchronize() and could caused
flushing of first buffers or ressampler being inserted.

This also fixes playback with audio devices having a long delay (>= 350ms).
Depending on few options (like the rate), VLC was never able to catch up with
this first valid delay (so it was flushing in loop).

This commit apply for both macOS and iOS.

cf. https://code.videolan.org/videolan/vlc-ios/issues/344

(cherry picked from commit bdd96900164739b72220334bdbda511aff708caa)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=704bd1291f203684cb5b87841697a4f68714dea6
---

 modules/audio_output/coreaudio_common.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
index 6e2b5ed14d..22a519a3b8 100644
--- a/modules/audio_output/coreaudio_common.c
+++ b/modules/audio_output/coreaudio_common.c
@@ -211,15 +211,15 @@ ca_TimeGet(audio_output_t *p_aout, mtime_t *delay)
 
     lock_lock(p_sys);
 
-    mtime_t i_render_delay;
-    if (likely(p_sys->i_render_host_time != 0))
+    if (p_sys->i_render_host_time == 0)
     {
-        const uint64_t i_render_time_us = p_sys->i_render_host_time
-                                        * tinfo.numer / tinfo.denom / 1000;
-        i_render_delay = i_render_time_us - mdate();
+        lock_unlock(p_sys);
+        return -1;
     }
-    else
-        i_render_delay = 0;
+
+    const uint64_t i_render_time_us = p_sys->i_render_host_time
+                                    * tinfo.numer / tinfo.denom / 1000;
+    const mtime_t i_render_delay = i_render_time_us - mdate();
 
     const int64_t i_out_frames = BytesToFrames(p_sys, p_sys->i_out_size);
     *delay = FramesToUs(p_sys, i_out_frames + p_sys->i_render_frames)



More information about the vlc-commits mailing list