diff options
author | wm4 <wm4@nowhere> | 2014-02-20 13:38:39 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-03-11 00:14:30 +0100 |
commit | 89f20cd2f35ad25271ac91606ec459467d61a0ed (patch) | |
tree | 3dfa4e4d9da5c77997d5a1e1823b6e29d90bcf00 /input | |
parent | cce2b675acaef005720faed63106f7d98da7253e (diff) | |
download | mpv-89f20cd2f35ad25271ac91606ec459467d61a0ed.tar.bz2 mpv-89f20cd2f35ad25271ac91606ec459467d61a0ed.tar.xz |
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.
Diffstat (limited to 'input')
-rw-r--r-- | input/cmd_list.c | 16 | ||||
-rw-r--r-- | input/cmd_list.h | 3 | ||||
-rw-r--r-- | input/input.c | 4 |
3 files changed, 19 insertions, 4 deletions
diff --git a/input/cmd_list.c b/input/cmd_list.c index 05dcb72d25..bb7d2413f8 100644 --- a/input/cmd_list.c +++ b/input/cmd_list.c @@ -253,7 +253,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: @@ -264,6 +264,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++) { diff --git a/input/cmd_list.h b/input/cmd_list.h index 211df2b0b0..870294cfaf 100644 --- a/input/cmd_list.h +++ b/input/cmd_list.h @@ -107,7 +107,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); diff --git a/input/input.c b/input/input.c index def7b77710..56c21b4fe1 100644 --- a/input/input.c +++ b/input/input.c @@ -237,7 +237,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; } @@ -580,7 +580,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) |