1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 08:12:17 +00:00

command: make "subprocess" explicitly abortable

Now mpv_abort_async_command() can be used to stop the process.
This commit is contained in:
wm4 2018-05-12 18:47:43 +02:00
parent e4fb23ed7d
commit 9c530c7ee9
2 changed files with 9 additions and 5 deletions

View File

@ -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.

View File

@ -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 } },