diff options
author | wm4 <wm4@nowhere> | 2018-05-12 18:47:43 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2018-05-24 19:56:34 +0200 |
commit | 9c530c7ee9ac0641e58ac1203bd46675e8700cc5 (patch) | |
tree | 1c8b867a0909c833c17d717cb70dc19f6e577799 | |
parent | e4fb23ed7de874bb2d05824d7edb84cfd1b21101 (diff) | |
download | mpv-9c530c7ee9ac0641e58ac1203bd46675e8700cc5.tar.bz2 mpv-9c530c7ee9ac0641e58ac1203bd46675e8700cc5.tar.xz |
command: make "subprocess" explicitly abortable
Now mpv_abort_async_command() can be used to stop the process.
-rw-r--r-- | DOCS/man/input.rst | 2 | ||||
-rw-r--r-- | player/command.c | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 6d05c5fc5d..cadf515567 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -363,6 +363,8 @@ List of Input Commands it was somehow killed or returned an error status has to be queried from the result value. + This command can be asynchronously aborted via API. + ``quit [<code>]`` Exit the player. If an argument is given, it's used as process exit code. diff --git a/player/command.c b/player/command.c index cd623c03f4..ffe9683adb 100644 --- a/player/command.c +++ b/player/command.c @@ -5700,15 +5700,16 @@ static void cmd_subprocess(void *p) .capture = {0, cmd->args[3].v.i, cmd->args[4].v.i}, }; - struct mp_cancel *cancel = NULL; - if (playback_only) - cancel = mpctx->playback_abort; + pthread_mutex_lock(&mpctx->abort_lock); + cmd->abort->coupled_to_playback = playback_only; + mp_abort_recheck_locked(mpctx, cmd->abort); + pthread_mutex_unlock(&mpctx->abort_lock); mp_core_unlock(mpctx); char *error = NULL; - int status = mp_subprocess(args, cancel, &ctx, subprocess_stdout, - subprocess_stderr, &error); + int status = mp_subprocess(args, cmd->abort->cancel, &ctx, + subprocess_stdout, subprocess_stderr, &error); mp_core_lock(mpctx); @@ -6156,6 +6157,7 @@ const struct mp_cmd_def mp_cmds[] = { OPT_FLAG("capture_stderr", v.i, 0, OPTDEF_INT(0)), }, .spawn_thread = true, + .can_abort = true, }, { "set", cmd_set, { ARG_STRING, ARG_STRING } }, |