mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
9cf2c67910
Signed-off-by: Thiago Kenji Okada <thiagokokada@gmail.com>
58 lines
1.6 KiB
Diff
58 lines
1.6 KiB
Diff
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
|
|
|