mirror of
https://github.com/mpv-player/mpv
synced 2024-12-24 07:42:17 +00:00
player: don't enter playloop for client API requests
This _actually_ does what commit 8716c2e8
promised, and gives a slight
performance improvement for client API users which make a lot of
requests (like reading properties).
The main issue was that mp_dispatch_lock() (which client.c uses to get
exclusive access to the core) still called the wakeup callback, which
made mp_dispatch_queue_process() exit. So the playloop got executed
again, and since it does a lot of stuff, performance could be reduced.
This commit is contained in:
parent
56616b0b01
commit
4395a4f837
@ -122,6 +122,10 @@ static void mp_dispatch_append(struct mp_dispatch_queue *queue,
|
|||||||
// Wake up the main thread; note that other threads might wait on this
|
// Wake up the main thread; note that other threads might wait on this
|
||||||
// condition for reasons, so broadcast the condition.
|
// condition for reasons, so broadcast the condition.
|
||||||
pthread_cond_broadcast(&queue->cond);
|
pthread_cond_broadcast(&queue->cond);
|
||||||
|
// No wakeup callback -> assume mp_dispatch_queue_process() needs to be
|
||||||
|
// interrupted instead.
|
||||||
|
if (!queue->wakeup_fn)
|
||||||
|
queue->interrupted = true;
|
||||||
pthread_mutex_unlock(&queue->lock);
|
pthread_mutex_unlock(&queue->lock);
|
||||||
if (queue->wakeup_fn)
|
if (queue->wakeup_fn)
|
||||||
queue->wakeup_fn(queue->wakeup_ctx);
|
queue->wakeup_fn(queue->wakeup_ctx);
|
||||||
|
@ -182,7 +182,6 @@ void mp_destroy(struct MPContext *mpctx)
|
|||||||
cas_terminal_owner(mpctx, NULL);
|
cas_terminal_owner(mpctx, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_dispatch_set_wakeup_fn(mpctx->dispatch, NULL, NULL);
|
|
||||||
mp_input_uninit(mpctx->input);
|
mp_input_uninit(mpctx->input);
|
||||||
|
|
||||||
uninit_libav(mpctx->global);
|
uninit_libav(mpctx->global);
|
||||||
@ -356,7 +355,6 @@ struct MPContext *mp_create(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mp_input_set_cancel(mpctx->input, mpctx->playback_abort);
|
mp_input_set_cancel(mpctx->input, mpctx->playback_abort);
|
||||||
mp_dispatch_set_wakeup_fn(mpctx->dispatch, wakeup_playloop, mpctx);
|
|
||||||
|
|
||||||
return mpctx;
|
return mpctx;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user