[vlc-commits] coreaudio: always return a valid delay

Thomas Guillem git at videolan.org
Thu Jun 21 10:23:00 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Jun 21 09:41:27 2018 +0200| [7a098bbaac82471b11a9c63490f9d6a7462bc817] | committer: Thomas Guillem

coreaudio: always return a valid delay

Even if the render callbacks is not yet called.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7a098bbaac82471b11a9c63490f9d6a7462bc817
---

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

diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
index e43fcf6602..fe5f2bae41 100644
--- a/modules/audio_output/coreaudio_common.c
+++ b/modules/audio_output/coreaudio_common.c
@@ -206,20 +206,24 @@ ca_TimeGet(audio_output_t *p_aout, mtime_t *delay)
 {
     struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
 
+    if (unlikely(tinfo.denom == 0))
+        return -1;
+
     lock_lock(p_sys);
 
-    if (tinfo.denom == 0 || p_sys->i_render_host_time == 0)
+    mtime_t i_render_delay;
+    if (likely(p_sys->i_render_host_time != 0))
     {
-        lock_unlock(p_sys);
-        return -1;
+        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();
     }
-
-    const uint64_t i_render_time_us = p_sys->i_render_host_time
-                                    * tinfo.numer / tinfo.denom / 1000;
+    else
+        i_render_delay = 0;
 
     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)
-           + p_sys->i_dev_latency_us + i_render_time_us - mdate();
+           + p_sys->i_dev_latency_us + i_render_delay;
 
     lock_unlock(p_sys);
     return 0;



More information about the vlc-commits mailing list