From b3968ecf05c11cf42c8120be3a1d716c4cc71b5d Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 19 May 2018 18:44:03 +0200 Subject: input: remove now unused "abort command" and cancel infrastructure The previous commit removed all uses. --- input/cmd.c | 28 ---------------------------- input/cmd.h | 7 ------- input/input.c | 33 ++------------------------------- input/input.h | 4 ---- player/command.c | 10 +++++----- 5 files changed, 7 insertions(+), 75 deletions(-) diff --git a/input/cmd.c b/input/cmd.c index 0a6bd73931..f0bb53e040 100644 --- a/input/cmd.c +++ b/input/cmd.c @@ -552,34 +552,6 @@ void mp_cmd_dump(struct mp_log *log, int msgl, char *header, struct mp_cmd *cmd) mp_msg(log, msgl, "]\n"); } -// 0: no, 1: maybe, 2: sure -static int is_abort_cmd(struct mp_cmd *cmd) -{ - if (cmd->def->is_abort) - return 2; - if (cmd->def->is_soft_abort) - return 1; - 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); - r = MPMAX(r, x); - } - return r; - } - return 0; -} - -bool mp_input_is_maybe_abort_cmd(struct mp_cmd *cmd) -{ - return is_abort_cmd(cmd) >= 1; -} - -bool mp_input_is_abort_cmd(struct mp_cmd *cmd) -{ - return is_abort_cmd(cmd) >= 2; -} - bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd) { return (cmd->def->allow_auto_repeat) || cmd->def == &mp_cmd_list || diff --git a/input/cmd.h b/input/cmd.h index a2cbaae510..2d9c922230 100644 --- a/input/cmd.h +++ b/input/cmd.h @@ -39,8 +39,6 @@ struct mp_cmd_def { bool on_updown; // always emit it on both up and down key events bool vararg; // last argument can be given 0 to multiple times bool scalable; - bool is_abort; - bool is_soft_abort; bool is_ignore; bool default_async; // default to MP_ASYNC flag if none set by user // If you set this, handler() must ensure mp_cmd_ctx_complete() is called @@ -121,11 +119,6 @@ typedef struct mp_cmd { extern const struct mp_cmd_def mp_cmds[]; extern const struct mp_cmd_def mp_cmd_list; -// Executing this command will maybe abort playback (play something else, or quit). -bool mp_input_is_maybe_abort_cmd(struct mp_cmd *cmd); -// This command will definitely abort playback. -bool mp_input_is_abort_cmd(struct mp_cmd *cmd); - bool mp_input_is_repeatable_cmd(struct mp_cmd *cmd); bool mp_input_is_scalable_cmd(struct mp_cmd *cmd); diff --git a/input/input.c b/input/input.c index 20c39dd4ac..c8f1a64ad5 100644 --- a/input/input.c +++ b/input/input.c @@ -153,9 +153,6 @@ struct input_ctx { struct cmd_queue cmd_queue; - void (*cancel)(void *cancel_ctx); - void *cancel_ctx; - void (*wakeup_cb)(void *ctx); void *wakeup_ctx; }; @@ -531,13 +528,11 @@ static void release_down_cmd(struct input_ctx *ictx, bool drop_current) } // We don't want the append to the command queue indefinitely, because that -// could lead to situations where recovery would take too long. On the other -// hand, don't drop commands that will abort playback. +// could lead to situations where recovery would take too long. 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->opts->key_fifo_size && - !mp_input_is_abort_cmd(cmd); + return queue_count_cmds(queue) >= ictx->opts->key_fifo_size; } static struct mp_cmd *resolve_key(struct input_ctx *ictx, int code) @@ -883,26 +878,10 @@ static void adjust_max_wait_time(struct input_ctx *ictx, double *time) } } -static bool test_abort_cmd(struct input_ctx *ictx, struct mp_cmd *new) -{ - if (!mp_input_is_maybe_abort_cmd(new)) - return false; - if (mp_input_is_abort_cmd(new)) - return true; - // Abort only if there are going to be at least 2 commands in the queue. - for (struct mp_cmd *cmd = ictx->cmd_queue.first; cmd; cmd = cmd->queue_next) { - if (mp_input_is_maybe_abort_cmd(cmd)) - return true; - } - return false; -} - int mp_input_queue_cmd(struct input_ctx *ictx, mp_cmd_t *cmd) { input_lock(ictx); if (cmd) { - if (ictx->cancel && test_abort_cmd(ictx, cmd)) - ictx->cancel(ictx->cancel_ctx); queue_add_tail(&ictx->cmd_queue, cmd); mp_input_wakeup(ictx); } @@ -1423,14 +1402,6 @@ void mp_input_uninit(struct input_ctx *ictx) talloc_free(ictx); } -void mp_input_set_cancel(struct input_ctx *ictx, void (*cb)(void *c), void *c) -{ - input_lock(ictx); - ictx->cancel = cb; - ictx->cancel_ctx = c; - input_unlock(ictx); -} - bool mp_input_use_alt_gr(struct input_ctx *ictx) { input_lock(ictx); diff --git a/input/input.h b/input/input.h index 1641f9fad6..ff194785c9 100644 --- a/input/input.h +++ b/input/input.h @@ -193,10 +193,6 @@ double mp_input_get_delay(struct input_ctx *ictx); // Wake up sleeping input loop from another thread. void mp_input_wakeup(struct input_ctx *ictx); -// Used to asynchronously abort playback. Needed because the core still can -// block on network in some situations. -void mp_input_set_cancel(struct input_ctx *ictx, void (*cb)(void *c), void *c); - // If this returns true, use Right Alt key as Alt Gr to produce special // characters. If false, count Right Alt as the modifier Alt key. bool mp_input_use_alt_gr(struct input_ctx *ictx); diff --git a/player/command.c b/player/command.c index efd1304720..629ff234e2 100644 --- a/player/command.c +++ b/player/command.c @@ -6059,10 +6059,10 @@ const struct mp_cmd_def mp_cmds[] = { {OPT_FLAGS("flags", v.i, MP_CMD_OPT_ARG, ({"mark", 1}))}, }, { "quit", cmd_quit, { OPT_INT("code", v.i, MP_CMD_OPT_ARG) }, - .priv = &(const bool){0}, .is_abort = true }, + .priv = &(const bool){0} }, { "quit-watch-later", cmd_quit, { OPT_INT("code", v.i, MP_CMD_OPT_ARG) }, - .priv = &(const bool){1}, .is_abort = true }, - { "stop", cmd_stop, .is_abort = true }, + .priv = &(const bool){1} }, + { "stop", cmd_stop, }, { "frame-step", cmd_frame_step, .allow_auto_repeat = true, .on_updown = true }, { "frame-back-step", cmd_frame_back_step, .allow_auto_repeat = true }, @@ -6071,14 +6071,14 @@ const struct mp_cmd_def mp_cmds[] = { OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG, ({"weak", 0}, {"force", 1})), }, - .is_soft_abort = true, .priv = &(const int){1}, + .priv = &(const int){1}, }, { "playlist-prev", cmd_playlist_next_prev, { OPT_CHOICE("flags", v.i, MP_CMD_OPT_ARG, ({"weak", 0}, {"force", 1})), }, - .is_soft_abort = true, .priv = &(const int){-1}, + .priv = &(const int){-1}, }, { "playlist-shuffle", cmd_playlist_shuffle, }, { "sub-step", cmd_sub_step_seek, { OPT_INT("skip", v.i, 0) }, -- cgit v1.2.3