diff options
author | wm4 <wm4@nowhere> | 2014-09-13 16:47:30 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-13 16:47:30 +0200 |
commit | 893f4a0feebde98247141855700173011bdeb353 (patch) | |
tree | 8c5c2a0579a8e438df57accbb418026a3d38b4cc /input/input.c | |
parent | 2e91d44e2031c299de0d879e2656024d701c27da (diff) | |
download | mpv-893f4a0feebde98247141855700173011bdeb353.tar.bz2 mpv-893f4a0feebde98247141855700173011bdeb353.tar.xz |
input: distinguish playlist navigation and quit commands for abort
Refine the ugly hack from the previous commit, and let the "quit"
command and some others abort playback immediately. For
playlist_next/playlist_prev, still use the old hack, because we can't
know if they would stop playback or not.
Diffstat (limited to 'input/input.c')
-rw-r--r-- | input/input.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/input/input.c b/input/input.c index 3e9b40d158..02589e1941 100644 --- a/input/input.c +++ b/input/input.c @@ -245,17 +245,6 @@ static int queue_count_cmds(struct cmd_queue *queue) return res; } -static bool has_abort_cmds(struct input_ctx *ictx) -{ - bool ret = false; - for (struct mp_cmd *cmd = ictx->cmd_queue.first; cmd; cmd = cmd->queue_next) - if (mp_input_is_abort_cmd(cmd)) { - ret = true; - break; - } - return ret; -} - static void queue_remove(struct cmd_queue *queue, struct mp_cmd *cmd) { struct mp_cmd **p_prev = &queue->first; @@ -794,12 +783,25 @@ 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) { - // Abort only if there are going to be at least 2 commands in the queue. - if (ictx->cancel && mp_input_is_abort_cmd(cmd) && has_abort_cmds(ictx)) + if (ictx->cancel && test_abort_cmd(ictx, cmd)) mp_cancel_trigger(ictx->cancel); queue_add_tail(&ictx->cmd_queue, cmd); mp_input_wakeup(ictx); |