summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_wasapi_utils.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 /audio/out/ao_wasapi_utils.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 'audio/out/ao_wasapi_utils.c')
-rw-r--r--audio/out/ao_wasapi_utils.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c
index 07c7ddb43f..6c5bfb3ab1 100644
--- a/audio/out/ao_wasapi_utils.c
+++ b/audio/out/ao_wasapi_utils.c
@@ -945,7 +945,7 @@ bool wasapi_thread_init(struct ao *ao)
{
struct wasapi_state *state = ao->priv;
MP_DBG(ao, "Init wasapi thread\n");
- int64_t retry_wait = 1;
+ int64_t retry_wait = 1000;
bool align_hack = false;
HRESULT hr;
@@ -1028,13 +1028,13 @@ retry:
goto retry;
case AUDCLNT_E_DEVICE_IN_USE:
case AUDCLNT_E_DEVICE_INVALIDATED:
- if (retry_wait > 8) {
+ if (retry_wait > 8000) {
MP_FATAL(ao, "Bad device retry failed\n");
return false;
}
wasapi_thread_uninit(ao);
MP_WARN(ao, "Retrying in %"PRId64" us\n", retry_wait);
- mp_sleep_us(retry_wait);
+ mp_sleep_ns(retry_wait);
retry_wait *= 2;
goto retry;
}