mirror of https://github.com/mpv-player/mpv
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:
parent
0fd8f0b3c1
commit
9ac0085031
|
@ -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)
|
void mp_dispatch_queue_process(struct mp_dispatch_queue *queue, double timeout)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&queue->lock);
|
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
|
assert(!queue->in_process); // recursion not allowed
|
||||||
queue->in_process = true;
|
queue->in_process = true;
|
||||||
queue->in_process_thread = pthread_self();
|
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;
|
item->completed = true;
|
||||||
}
|
}
|
||||||
} else if (queue->wait > 0 && !queue->interrupted) {
|
} 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))
|
if (pthread_cond_timedwait(&queue->cond, &queue->lock, &ts))
|
||||||
queue->wait = 0;
|
queue->wait = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -75,7 +75,7 @@ void mp_set_timeout(struct MPContext *mpctx, double sleeptime)
|
||||||
{
|
{
|
||||||
if (mpctx->sleeptime > sleeptime) {
|
if (mpctx->sleeptime > sleeptime) {
|
||||||
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);
|
mp_dispatch_adjust_timeout(mpctx->dispatch, abstime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue