From 08ae71fee3a79ac3da4032768a0aa3b7793bc1a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sun, 22 Oct 2023 04:24:54 +0200 Subject: [PATCH] timer: remove unnecesary time conversions --- misc/thread_pool.c | 2 +- video/out/cocoa_common.m | 2 +- video/out/vo_libmpv.c | 2 +- video/out/vo_rpi.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/thread_pool.c b/misc/thread_pool.c index f57dc8cfcfd51..e20d9d07e616c 100644 --- a/misc/thread_pool.c +++ b/misc/thread_pool.c @@ -71,7 +71,7 @@ static MP_THREAD_VOID worker_thread(void *arg) if (pool->num_threads > pool->min_threads) { if (!destroy_deadline) - destroy_deadline = mp_time_ns_add(mp_time_ns(), DESTROY_TIMEOUT); + destroy_deadline = mp_time_ns() + MP_TIME_S_TO_NS(DESTROY_TIMEOUT); if (mp_cond_timedwait_until(&pool->wakeup, &pool->lock, destroy_deadline)) got_timeout = pool->num_threads > pool->min_threads; } else { diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 812bce1148fd5..a9993f1cbe615 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -787,7 +787,7 @@ static void vo_cocoa_resize_redraw(struct vo *vo, int width, int height) // Wait until a new frame with the new size was rendered. For some reason, // Cocoa requires this to be done before drawRect() returns. - int64_t e = mp_time_ns_add(mp_time_ns(), 0.1); + int64_t e = mp_time_ns() + MP_TIME_MS_TO_NS(100); while (s->frame_w != width && s->frame_h != height && s->vo_ready) { if (mp_cond_timedwait(&s->wakeup, &s->lock, e)) break; diff --git a/video/out/vo_libmpv.c b/video/out/vo_libmpv.c index 1efdcdd75ba7e..972588ee3eaf9 100644 --- a/video/out/vo_libmpv.c +++ b/video/out/vo_libmpv.c @@ -500,7 +500,7 @@ static void flip_page(struct vo *vo) { struct vo_priv *p = vo->priv; struct mpv_render_context *ctx = p->ctx; - int64_t until = mp_time_ns_add(mp_time_ns(), 0.2); + int64_t until = mp_time_ns() + MP_TIME_MS_TO_NS(200); mp_mutex_lock(&ctx->lock); diff --git a/video/out/vo_rpi.c b/video/out/vo_rpi.c index e0ee85c162e90..55f1a68edb49c 100644 --- a/video/out/vo_rpi.c +++ b/video/out/vo_rpi.c @@ -477,7 +477,7 @@ static void wait_next_vsync(struct vo *vo) { struct priv *p = vo->priv; mp_mutex_lock(&p->display_mutex); - int64_t end = mp_time_ns_add(mp_time_ns(), 0.050); + int64_t end = mp_time_ns() + MP_TIME_MS_TO_NS(50); int64_t old = p->vsync_counter; while (old == p->vsync_counter && !p->reload_display) { if (mp_cond_timedwait_until(&p->display_cond, &p->display_mutex, end))