summaryrefslogtreecommitdiffstats
path: root/osdep/timer-win2.c
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-09-29 17:24:21 -0500
committerDudemanguy <random342@airmail.cc>2023-10-10 19:10:55 +0000
commit59dd7d94af7651baf7e60966c5f8e7d52959d958 (patch)
treec6eb2938d2a63ebb07e377794f28ca708d786abd /osdep/timer-win2.c
parentfcebee9080a113f3248d218e451345db3f965b47 (diff)
downloadmpv-59dd7d94af7651baf7e60966c5f8e7d52959d958.tar.bz2
mpv-59dd7d94af7651baf7e60966c5f8e7d52959d958.tar.xz
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.
Diffstat (limited to 'osdep/timer-win2.c')
-rw-r--r--osdep/timer-win2.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/osdep/timer-win2.c b/osdep/timer-win2.c
index dd7a42f0d1..db4c39d7ef 100644
--- a/osdep/timer-win2.c
+++ b/osdep/timer-win2.c
@@ -52,17 +52,17 @@ void mp_end_hires_timers(int res_ms)
#endif
}
-void mp_sleep_us(int64_t us)
+void mp_sleep_ns(int64_t ns)
{
- if (us < 0)
+ if (ns < 0)
return;
// Sleep(0) won't sleep for one clocktick as the unix usleep
// instead it will only make the thread ready
// it may take some time until it actually starts to run again
- if (us < 1000)
- us = 1000;
- int hrt = mp_start_hires_timers(us / 1000);
- Sleep(us / 1000);
+ if (ns < 1e6)
+ ns = 1e6;
+ int hrt = mp_start_hires_timers(ns / 1e6);
+ Sleep(ns / 1e6);
mp_end_hires_timers(hrt);
}