mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
input: check for abort cmd in multi-commands
MP_CMD_COMMAND_LIST commands (used to implement key bindings with multiple commands) were not checked for abort commands. Implement it. Remove the remarks about multi-commands being special from the manpage. Seek coalescing is handled differently now, and the issue with abort commands is fixed with this commit.
This commit is contained in:
parent
1d0730d22d
commit
857952dce3
@ -52,11 +52,6 @@ You can bind multiple commands to one key. For example:
|
||||
|
||||
| a show_text "command 1" ; show_text "command 2"
|
||||
|
||||
Note that some magic is disabled for keys: seek commands inside lists are not
|
||||
coalesced (seeking will appear slower), and no check is done for abort commands
|
||||
(so these commands can't be used to abort playback if the network cache is
|
||||
stuck).
|
||||
|
||||
List of Input Commands
|
||||
----------------------
|
||||
|
||||
|
@ -255,7 +255,7 @@ bool mp_replace_legacy_cmd(void *t, bstr *s)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool mp_input_is_abort_cmd(int cmd_id)
|
||||
static bool is_abort_cmd(int cmd_id)
|
||||
{
|
||||
switch (cmd_id) {
|
||||
case MP_CMD_QUIT:
|
||||
@ -266,6 +266,20 @@ bool mp_input_is_abort_cmd(int cmd_id)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool mp_input_is_abort_cmd(struct mp_cmd *cmd)
|
||||
{
|
||||
if (is_abort_cmd(cmd->id))
|
||||
return true;
|
||||
if (cmd->id == MP_CMD_COMMAND_LIST) {
|
||||
for (struct mp_cmd *sub = cmd->args[0].v.p; sub; sub = sub->queue_next)
|
||||
{
|
||||
if (mp_input_is_abort_cmd(cmd))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void mp_print_cmd_list(struct mp_log *out)
|
||||
{
|
||||
for (int i = 0; mp_cmds[i].name; i++) {
|
||||
|
@ -108,7 +108,8 @@ enum mp_command_type {
|
||||
};
|
||||
|
||||
// Executing this command will abort playback (play something else, or quit).
|
||||
bool mp_input_is_abort_cmd(int cmd_id);
|
||||
struct mp_cmd;
|
||||
bool mp_input_is_abort_cmd(struct mp_cmd *cmd);
|
||||
|
||||
struct bstr;
|
||||
bool mp_replace_legacy_cmd(void *talloc_ctx, struct bstr *s);
|
||||
|
@ -238,7 +238,7 @@ static bool queue_has_abort_cmds(struct cmd_queue *queue)
|
||||
{
|
||||
bool ret = false;
|
||||
for (struct mp_cmd *cmd = queue->first; cmd; cmd = cmd->queue_next)
|
||||
if (mp_input_is_abort_cmd(cmd->id)) {
|
||||
if (mp_input_is_abort_cmd(cmd)) {
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
@ -584,7 +584,7 @@ static bool should_drop_cmd(struct input_ctx *ictx, struct mp_cmd *cmd)
|
||||
{
|
||||
struct cmd_queue *queue = &ictx->cmd_queue;
|
||||
return (queue_count_cmds(queue) >= ictx->key_fifo_size &&
|
||||
(!mp_input_is_abort_cmd(cmd->id) || queue_has_abort_cmds(queue)));
|
||||
(!mp_input_is_abort_cmd(cmd) || queue_has_abort_cmds(queue)));
|
||||
}
|
||||
|
||||
static void interpret_key(struct input_ctx *ictx, int code, double scale)
|
||||
|
@ -1024,7 +1024,7 @@ static bool demux_was_interrupted(struct MPContext *mpctx)
|
||||
mp_cmd_t *cmd = mp_input_get_cmd(mpctx->input, 0, 0);
|
||||
if (!cmd)
|
||||
break;
|
||||
if (mp_input_is_abort_cmd(cmd->id))
|
||||
if (mp_input_is_abort_cmd(cmd))
|
||||
run_command(mpctx, cmd);
|
||||
mp_cmd_free(cmd);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user