diff options
-rw-r--r-- | audio/out/ao_wasapi_utils.c | 6 | ||||
-rw-r--r-- | osdep/timer.h | 10 | ||||
-rw-r--r-- | video/out/opengl/hwdec_dxva2egl.c | 4 | ||||
-rw-r--r-- | video/out/vo_x11.c | 2 | ||||
-rw-r--r-- | video/out/vo_xv.c | 2 |
5 files changed, 17 insertions, 7 deletions
diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 6c5bfb3ab1..e26e591ba8 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 = 1000; + int64_t retry_wait = MP_TIME_US_TO_NS(1); bool align_hack = false; HRESULT hr; @@ -1028,12 +1028,12 @@ retry: goto retry; case AUDCLNT_E_DEVICE_IN_USE: case AUDCLNT_E_DEVICE_INVALIDATED: - if (retry_wait > 8000) { + if (retry_wait > MP_TIME_US_TO_NS(8)) { 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_WARN(ao, "Retrying in %"PRId64" ns\n", retry_wait); mp_sleep_ns(retry_wait); retry_wait *= 2; goto retry; diff --git a/osdep/timer.h b/osdep/timer.h index b273cb405e..efbfc4e358 100644 --- a/osdep/timer.h +++ b/osdep/timer.h @@ -50,6 +50,16 @@ void mp_end_hires_timers(int resolution_ms); #define MP_START_TIME 10 * INT64_C(1000000000) +// Converts time units to nanoseconds (int64_t) +#define MP_TIME_S_TO_NS(s) ((s) * INT64_C(1000000000)) +#define MP_TIME_MS_TO_NS(ms) ((ms) * INT64_C(1000000)) +#define MP_TIME_US_TO_NS(us) ((us) * INT64_C(1000)) + +// Converts nanoseconds to specified time unit (double) +#define MP_TIME_NS_TO_S(ns) ((ns) / (double)1000000000) +#define MP_TIME_NS_TO_MS(ns) ((ns) / (double)1000000) +#define MP_TIME_NS_TO_US(ns) ((ns) / (double)1000) + // Duration of a second in mpv time. #define MP_SECOND_US (1000 * 1000) diff --git a/video/out/opengl/hwdec_dxva2egl.c b/video/out/opengl/hwdec_dxva2egl.c index acf3ec00c4..979ef59745 100644 --- a/video/out/opengl/hwdec_dxva2egl.c +++ b/video/out/opengl/hwdec_dxva2egl.c @@ -343,7 +343,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) // of the above StretchRect. Timeout of 8ms is required to reliably // render 4k on Intel Haswell, Ivybridge and Cherry Trail Atom. const int max_retries = 8; - const int64_t wait_ns = 1e6; + const int64_t wait_ns = MP_TIME_MS_TO_NS(1); int retries = 0; while (true) { hr = IDirect3DQuery9_GetData(p->query9, NULL, 0, D3DGETDATA_FLUSH); @@ -353,7 +353,7 @@ static int mapper_map(struct ra_hwdec_mapper *mapper) } else if (hr == S_FALSE) { if (++retries > max_retries) { MP_VERBOSE(mapper, "Failed to flush frame after %lld ms\n", - (long long)(wait_ns * max_retries) / 1000000); + (long long)MP_TIME_MS_TO_NS(wait_ns * max_retries)); break; } mp_sleep_ns(wait_ns); diff --git a/video/out/vo_x11.c b/video/out/vo_x11.c index 1087fc249e..fa9315726d 100644 --- a/video/out/vo_x11.c +++ b/video/out/vo_x11.c @@ -299,7 +299,7 @@ static void wait_for_completion(struct vo *vo, int max_outstanding) " for XShm completion events...\n"); ctx->Shm_Warned_Slow = 1; } - mp_sleep_ns(1e6); + mp_sleep_ns(MP_TIME_MS_TO_NS(1)); vo_x11_check_events(vo); } } diff --git a/video/out/vo_xv.c b/video/out/vo_xv.c index cffd3a797f..6c776c507b 100644 --- a/video/out/vo_xv.c +++ b/video/out/vo_xv.c @@ -670,7 +670,7 @@ static void wait_for_completion(struct vo *vo, int max_outstanding) " for XShm completion events...\n"); ctx->Shm_Warned_Slow = 1; } - mp_sleep_ns(1e6); + mp_sleep_ns(MP_TIME_MS_TO_NS(1)); vo_x11_check_events(vo); } } |