summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-12 16:29:25 +0100
committerwm4 <wm4@nowhere>2017-01-12 16:29:37 +0100
commitac98ff71ddf3da7d864f149fc290fa07600b311a (patch)
treea1caf6b884ca9a488396b52811f8a83eee203d63
parente552f5342ea9142d1d9ac2623caf4acb120a25c5 (diff)
downloadmpv-ac98ff71ddf3da7d864f149fc290fa07600b311a.tar.bz2
mpv-ac98ff71ddf3da7d864f149fc290fa07600b311a.tar.xz
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.
-rw-r--r--player/client.c8
1 files changed, 7 insertions, 1 deletions
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);