diff options
author | wm4 <wm4@nowhere> | 2018-04-30 20:33:05 +0200 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-05-03 01:20:01 +0300 |
commit | e8b073584d749bb864f495d9e1cd31b102c6283d (patch) | |
tree | fae1a577fadb7141c7035d9869c1842ec57b1a15 /input/cmd_list.c | |
parent | 14602b0201dfdbfd10c239fd978df5c269a71883 (diff) | |
download | mpv-e8b073584d749bb864f495d9e1cd31b102c6283d.tar.bz2 mpv-e8b073584d749bb864f495d9e1cd31b102c6283d.tar.xz |
input: remove some explicit uses of command IDs
The plan is to remove the command ID enum. This will happen by replacing
the big switch statement in command.c with dispatching to per-command
callbacks. As preparation, remove uses of the command IDs outside of the
actual dispatching mechanism.
Also remove some instances of checking cmd->def for NULL. We now require
this always to be set.
Diffstat (limited to 'input/cmd_list.c')
-rw-r--r-- | input/cmd_list.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/input/cmd_list.c b/input/cmd_list.c index 936cef9125..23a5da774e 100644 --- a/input/cmd_list.c +++ b/input/cmd_list.c @@ -30,15 +30,11 @@ // 0: no, 1: maybe, 2: sure static int is_abort_cmd(struct mp_cmd *cmd) { - switch (cmd->id) { - case MP_CMD_QUIT: - case MP_CMD_QUIT_WATCH_LATER: - case MP_CMD_STOP: + if (cmd->def->is_abort) return 2; - case MP_CMD_PLAYLIST_NEXT: - case MP_CMD_PLAYLIST_PREV: + if (cmd->def->is_soft_abort) return 1; - case MP_CMD_COMMAND_LIST:; + if (cmd->def == &mp_cmd_list) { int r = 0; for (struct mp_cmd *sub = cmd->args[0].v.p; sub; sub = sub->queue_next) { int x = is_abort_cmd(sub); @@ -61,14 +57,13 @@ bool mp_input_is_abort_cmd(struct mp_cmd *cmd) bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd) { - return (cmd->def && cmd->def->allow_auto_repeat) || - cmd->id == MP_CMD_COMMAND_LIST || + return (cmd->def->allow_auto_repeat) || cmd->def == &mp_cmd_list || (cmd->flags & MP_ALLOW_REPEAT); } bool mp_input_is_scalable_cmd(struct mp_cmd *cmd) { - return cmd->def && cmd->def->scalable; + return cmd->def->scalable; } void mp_print_cmd_list(struct mp_log *out) |