[vlc-commits] coreaudio: use os_unfair_lock symbols directly

Thomas Guillem git at videolan.org
Wed Nov 20 14:13:14 CET 2019


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Aug 16 09:57:49 2019 +0200| [4c9e348535d2e4043dec28bc3ea3b90d1b066422] | committer: Thomas Guillem

coreaudio: use os_unfair_lock symbols directly

And fix the timebase that was not initialized if the unfair_lock was not
available.

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

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

 modules/audio_output/coreaudio_common.c | 33 ++++++++++-----------------------
 1 file changed, 10 insertions(+), 23 deletions(-)

diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
index aca0e3f705..41917b6458 100644
--- a/modules/audio_output/coreaudio_common.c
+++ b/modules/audio_output/coreaudio_common.c
@@ -28,12 +28,6 @@
 #import <dlfcn.h>
 #import <mach/mach_time.h>
 
-static struct
-{
-    void (*lock)(os_unfair_lock *lock);
-    void (*unlock)(os_unfair_lock *lock);
-} unfair_lock;
-
 static mach_timebase_info_data_t tinfo;
 
 static inline uint64_t
@@ -89,47 +83,40 @@ ca_ClearOutBuffers(audio_output_t *p_aout)
 static void
 ca_init_once(void)
 {
-    unfair_lock.lock = os_unfair_lock_lock;
-    if (!unfair_lock.lock)
-        return;
-    unfair_lock.unlock = os_unfair_lock_unlock;
-    if (!unfair_lock.unlock)
-        unfair_lock.lock = NULL;
-
     if (mach_timebase_info(&tinfo) != KERN_SUCCESS)
         tinfo.numer = tinfo.denom = 0;
 }
 
-static void
+static inline void
 lock_init(struct aout_sys_common *p_sys)
 {
-    if (unfair_lock.lock)
+    if (likely(os_unfair_lock_lock))
         p_sys->lock.unfair = OS_UNFAIR_LOCK_INIT;
     else
         vlc_mutex_init(&p_sys->lock.mutex);
 }
 
-static void
+static inline void
 lock_destroy(struct aout_sys_common *p_sys)
 {
-    if (!unfair_lock.lock)
+    if (unlikely(!os_unfair_lock_lock))
         vlc_mutex_destroy(&p_sys->lock.mutex);
 }
 
-static void
+static inline void
 lock_lock(struct aout_sys_common *p_sys)
 {
-    if (unfair_lock.lock)
-        unfair_lock.lock(&p_sys->lock.unfair);
+    if (likely(os_unfair_lock_lock))
+        os_unfair_lock_lock(&p_sys->lock.unfair);
     else
         vlc_mutex_lock(&p_sys->lock.mutex);
 }
 
-static void
+static inline void
 lock_unlock(struct aout_sys_common *p_sys)
 {
-    if (unfair_lock.lock)
-        unfair_lock.unlock(&p_sys->lock.unfair);
+    if (likely(os_unfair_lock_lock))
+        os_unfair_lock_unlock(&p_sys->lock.unfair);
     else
         vlc_mutex_unlock(&p_sys->lock.mutex);
 }



More information about the vlc-commits mailing list