summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-10-21 23:55:32 +0200
committerwm4 <wm4@nowhere>2014-10-21 23:55:32 +0200
commit7eb047b2417d9b6cc3690fba75a50967a315955c (patch)
tree783920ae82245f663a388b08fc9c9acd23acedc1 /player
parent4d5903f9154439e480d9192c2e6dc7dce5ce112f (diff)
downloadmpv-7eb047b2417d9b6cc3690fba75a50967a315955c.tar.bz2
mpv-7eb047b2417d9b6cc3690fba75a50967a315955c.tar.xz
command: make reverse cycle_values match up with forward one
The behavior of reverse cycling (with the "!reverse" magic value) was a bit weird and acted with a "delay". This was because the command set the value the _next_ command should use. Change this and make each command invocation select and use the next command directly. This requires an "uninitialized" special index in the counter, but that is no problem at all.
Diffstat (limited to 'player')
-rw-r--r--player/command.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/player/command.c b/player/command.c
index 09fb75433a..c9f7f18d22 100644
--- a/player/command.c
+++ b/player/command.c
@@ -3650,7 +3650,7 @@ static int *get_cmd_cycle_counter(struct MPContext *mpctx, char **args)
if (stringlist_equals(ctr->args, args))
return &ctr->counter;
}
- struct cycle_counter ctr = {stringlist_dup(cmd, args), 0};
+ struct cycle_counter ctr = {stringlist_dup(cmd, args), -1};
MP_TARRAY_APPEND(cmd, cmd->cycle_counters, cmd->num_cycle_counters, ctr);
return &cmd->cycle_counters[cmd->num_cycle_counters - 1].counter;
}
@@ -3840,14 +3840,13 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
int *ptr = get_cmd_cycle_counter(mpctx, &args[first - 1]);
int count = cmd->nargs - first;
if (ptr && count > 0) {
- int next = *ptr;
- *ptr += dir;
+ *ptr = *ptr < 0 ? (dir > 0 ? 0 : -1) : *ptr + dir;
if (*ptr >= count)
*ptr = 0;
if (*ptr < 0)
*ptr = count - 1;
char *property = args[first - 1];
- char *value = args[first + next];
+ char *value = args[first + *ptr];
int r = mp_property_do(property, M_PROPERTY_SET_STRING, value, mpctx);
if (r == M_PROPERTY_OK || r == M_PROPERTY_UNAVAILABLE) {
show_property_osd(mpctx, property, on_osd);