From 9ac0085031aff86a9705514be270842f046dc002 Mon Sep 17 00:00:00 2001 From: Dudemanguy Date: Wed, 11 Oct 2023 14:32:48 -0500 Subject: [PATCH] dispatch: change mp_dispatch_queue_process timer to nanoseconds The playloop is the only thing that adjusts the timeout with a value other than 0, so nothing else needs to be changed. --- misc/dispatch.c | 4 ++-- player/playloop.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/dispatch.c b/misc/dispatch.c index 4d24409856..d88d775d97 100644 --- a/misc/dispatch.c +++ b/misc/dispatch.c @@ -272,7 +272,7 @@ void mp_dispatch_run(struct mp_dispatch_queue *queue, void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout) { pthread_mutex_lock(&queue->lock); - queue->wait = timeout > 0 ? mp_time_us_add(mp_time_us(), timeout) : 0; + queue->wait = timeout > 0 ? mp_time_ns_add(mp_time_ns(), timeout) : 0; assert(!queue->in_process); // recursion not allowed queue->in_process = true; queue->in_process_thread = pthread_self(); @@ -310,7 +310,7 @@ void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout) item->completed = true; } } else if (queue->wait > 0 && !queue->interrupted) { - struct timespec ts = mp_time_us_to_realtime(queue->wait); + struct timespec ts = mp_time_ns_to_realtime(queue->wait); if (pthread_cond_timedwait(&queue->cond, &queue->lock, &ts)) queue->wait = 0; } else { diff --git a/player/playloop.c b/player/playloop.c index eb42a3131c..60596da76d 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -75,7 +75,7 @@ void mp_set_timeout(struct MPContext *mpctx, double sleeptime) { if (mpctx->sleeptime > sleeptime) { mpctx->sleeptime = sleeptime; - int64_t abstime = mp_time_us_add(mp_time_us(), sleeptime); + int64_t abstime = mp_time_ns_add(mp_time_ns(), sleeptime); mp_dispatch_adjust_timeout(mpctx->dispatch, abstime); } }