summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-12 01:15:29 +0100
committerwm4 <wm4@nowhere>2013-12-12 01:25:21 +0100
commita937e93fd610d4c6f4f89532f562ee698535c9be (patch)
tree751a142bbbbf1bbe06ca1efa899ee418f5f02b6d
parentfcfd04409008cf1eed62b778f0b388023f00c005 (diff)
downloadmpv-a937e93fd610d4c6f4f89532f562ee698535c9be.tar.bz2
mpv-a937e93fd610d4c6f4f89532f562ee698535c9be.tar.xz
input: fix bogus section disabling, add debugging output
The code to remove a section from the active section array wasn't correct (it should have tried to copy the elements in reverse), so just replace it with a macro that does the intended thing. Add some debug output to print the section stack.
-rw-r--r--mpvcore/input/input.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/mpvcore/input/input.c b/mpvcore/input/input.c
index 8b31352f72..dbda34ed40 100644
--- a/mpvcore/input/input.c
+++ b/mpvcore/input/input.c
@@ -2190,9 +2190,8 @@ void mp_input_disable_section(struct input_ctx *ictx, char *name)
for (int i = ictx->num_active_sections - 1; i >= 0; i--) {
struct active_section *as = &ictx->active_sections[i];
if (strcmp(as->name, name) == 0) {
- for (int x = i; i < ictx->num_active_sections - 1; i++)
- ictx->active_sections[x] = ictx->active_sections[x + 1];
- ictx->num_active_sections--;
+ MP_TARRAY_REMOVE_AT(ictx->active_sections,
+ ictx->num_active_sections, i);
}
}
input_unlock(ictx);
@@ -2205,10 +2204,19 @@ void mp_input_enable_section(struct input_ctx *ictx, char *name, int flags)
mp_input_disable_section(ictx, name);
+ MP_VERBOSE(ictx, "enable section '%s'\n", name);
+
if (ictx->num_active_sections < MAX_ACTIVE_SECTIONS) {
ictx->active_sections[ictx->num_active_sections++] =
(struct active_section) {name, flags};
}
+
+ MP_DBG(ictx, "active section stack:\n");
+ for (int n = 0; n < ictx->num_active_sections; n++) {
+ MP_DBG(ictx, " %s %d\n", ictx->active_sections[n].name,
+ ictx->active_sections[n].flags);
+ }
+
input_unlock(ictx);
}