From 59dd7d94af7651baf7e60966c5f8e7d52959d958 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Fri, 29 Sep 2023 17:24:21 -0500 Subject: timer: change mp_sleep_us to mp_sleep_ns Linux and macOS already use nanosecond resolution for their sleep functions. It was just being converted from microseconds before. Since we have mp_time_ns now, go ahead and bump the precision here. The timer for windows uses some timeBeginPeriod thing which I'm not sure what it does really but whatever just convert the units to ms like they were doing before. There's really no reason to keep the mp_sleep_us helper around. A multiplication by 1000 is trivial and underlying OS clocks have nanosecond precision. --- osdep/timer-darwin.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'osdep/timer-darwin.c') diff --git a/osdep/timer-darwin.c b/osdep/timer-darwin.c index a114d0d727..bb8a9b4324 100644 --- a/osdep/timer-darwin.c +++ b/osdep/timer-darwin.c @@ -28,10 +28,9 @@ static double timebase_ratio_ns; -void mp_sleep_us(int64_t us) +void mp_sleep_ns(int64_t ns) { - uint64_t deadline = us * 1e3 / timebase_ratio_ns + mach_absolute_time(); - + uint64_t deadline = ns / timebase_ratio_ns + mach_absolute_time(); mach_wait_until(deadline); } -- cgit v1.2.3