about summary refs log tree commit diff
path: root/pkgs/servers/pulseaudio/0004-Prefer-clock_gettime.patch
blob: eb7bd1c6270879afcdc980d6dbc3b91a84238935 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From 0bd3b613ac3bf16a73b3223fa1b961da3a0db1b2 Mon Sep 17 00:00:00 2001
From: Andrew Childs <andrew.childs@bibo.com.ph>
Date: Tue, 19 Apr 2022 17:12:52 +0900
Subject: [PATCH 4/8] Prefer clock_gettime

Available in darwin since 10.12 (released in 2016).
---
 src/pulsecore/core-rtclock.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/pulsecore/core-rtclock.c b/src/pulsecore/core-rtclock.c
index 2c2e28631..a08d4b391 100644
--- a/src/pulsecore/core-rtclock.c
+++ b/src/pulsecore/core-rtclock.c
@@ -65,19 +65,7 @@ pa_usec_t pa_rtclock_age(const struct timeval *tv) {
 
 struct timeval *pa_rtclock_get(struct timeval *tv) {
 
-#if defined(OS_IS_DARWIN)
-    uint64_t val, abs_time = mach_absolute_time();
-    Nanoseconds nanos;
-
-    nanos = AbsoluteToNanoseconds(*(AbsoluteTime *) &abs_time);
-    val = *(uint64_t *) &nanos;
-
-    tv->tv_sec = val / PA_NSEC_PER_SEC;
-    tv->tv_usec = (val % PA_NSEC_PER_SEC) / PA_NSEC_PER_USEC;
-
-    return tv;
-
-#elif defined(HAVE_CLOCK_GETTIME)
+#if defined(HAVE_CLOCK_GETTIME)
     struct timespec ts;
 
 #ifdef CLOCK_MONOTONIC
@@ -109,6 +97,18 @@ struct timeval *pa_rtclock_get(struct timeval *tv) {
 
         return tv;
     }
+#elif defined(OS_IS_DARWIN)
+    uint64_t val, abs_time = mach_absolute_time();
+    Nanoseconds nanos;
+
+    nanos = AbsoluteToNanoseconds(*(AbsoluteTime *) &abs_time);
+    val = *(uint64_t *) &nanos;
+
+    tv->tv_sec = val / PA_NSEC_PER_SEC;
+    tv->tv_usec = (val % PA_NSEC_PER_SEC) / PA_NSEC_PER_USEC;
+
+    return tv;
+
 #endif /* HAVE_CLOCK_GETTIME */
 
     return pa_gettimeofday(tv);
-- 
2.35.1