From ac98ff71ddf3da7d864f149fc290fa07600b311a Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 12 Jan 2017 16:29:25 +0100 Subject: client API: fix freeze when destroying mpv_handle before mpv_initialize We have to perform some silly acrobatics to make the playback_thread() exit, as the mpv_command() will error out with MPV_ERROR_UNINITIALIZED. Test case: mpv_terminate_destroy(mpv_create()) Reported by a user on IRC. --- player/client.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'player') diff --git a/player/client.c b/player/client.c index cd22312bde..0b97945da2 100644 --- a/player/client.c +++ b/player/client.c @@ -407,7 +407,13 @@ void mpv_terminate_destroy(mpv_handle *ctx) if (!ctx) return; - mpv_command(ctx, (const char*[]){"quit", NULL}); + if (ctx->mpctx->initialized) { + mpv_command(ctx, (const char*[]){"quit", NULL}); + } else { + mp_dispatch_lock(ctx->mpctx->dispatch); + ctx->mpctx->stop_play = PT_QUIT; + mp_dispatch_unlock(ctx->mpctx->dispatch); + } if (!ctx->owner) { mpv_detach_destroy(ctx); -- cgit v1.2.3