mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
client API: fix init/destruction race conditions
mp_new_client() blatantly accessed some mutex-protected state outside of the mutex. The destruction code is in theory OK, but with changes in the following commits it'll be a bit hard to guarantee that it stays this way. Add a simple flag that makes adding new clients impossible, so that having no clients after shutdown_clients() remains guaranteed.
This commit is contained in:
@@ -152,20 +152,20 @@ void mp_print_version(struct mp_log *log, int always)
|
||||
|
||||
static void shutdown_clients(struct MPContext *mpctx)
|
||||
{
|
||||
while (mpctx->clients && mp_clients_num(mpctx)) {
|
||||
mp_client_enter_shutdown(mpctx);
|
||||
while (mp_clients_num(mpctx)) {
|
||||
mp_client_broadcast_event(mpctx, MPV_EVENT_SHUTDOWN, NULL);
|
||||
mp_dispatch_queue_process(mpctx->dispatch, 0);
|
||||
mp_wait_events(mpctx);
|
||||
}
|
||||
}
|
||||
|
||||
void mp_destroy(struct MPContext *mpctx)
|
||||
{
|
||||
shutdown_clients(mpctx);
|
||||
|
||||
mp_uninit_ipc(mpctx->ipc_ctx);
|
||||
mpctx->ipc_ctx = NULL;
|
||||
|
||||
shutdown_clients(mpctx);
|
||||
|
||||
uninit_audio_out(mpctx);
|
||||
uninit_video_out(mpctx);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user