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.
This commit is contained in:
Dudemanguy 2023-10-11 14:32:48 -05:00
parent 0fd8f0b3c1
commit 9ac0085031
2 changed files with 3 additions and 3 deletions

View File

@ -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 {

View File

@ -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);
}
}