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.
This commit is contained in:
wm4 2017-01-12 16:29:25 +01:00
parent e552f5342e
commit ac98ff71dd
1 changed files with 7 additions and 1 deletions

View File

@ -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);