summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-18 06:49:48 +0100
committerwm4 <wm4@nowhere>2019-12-18 06:49:48 +0100
commit9b9307ea9fa2a2f7f24b9ebec65ca622900af2f7 (patch)
tree3e67b909d20eac65d4342d614fae2a2d1a68562e
parent0a1588d39b2c30421909c87e60b1510ffd338497 (diff)
downloadmpv-9b9307ea9fa2a2f7f24b9ebec65ca622900af2f7.tar.bz2
mpv-9b9307ea9fa2a2f7f24b9ebec65ca622900af2f7.tar.xz
options: fix filter list comparison (again)
This was completely broken: it compared the first item of the filter list only. Apparently I forgot that this is a list. This probably broke aspects of runtime filter changing probably since commit b16cea750f52. Fix this, and remove some redundant code from obj_settings_equals(). Which is not the same as m_obj_settings_equal(), so rename it to make confusing them harder. (obj_setting_match() has these very weird label semantics that should probably just be killed. Or not.)
-rw-r--r--filters/f_output_chain.c3
-rw-r--r--options/m_option.c32
-rw-r--r--options/m_option.h2
3 files changed, 18 insertions, 19 deletions
diff --git a/filters/f_output_chain.c b/filters/f_output_chain.c
index 7686e4e642..1a6a910273 100644
--- a/filters/f_output_chain.c
+++ b/filters/f_output_chain.c
@@ -524,8 +524,7 @@ bool mp_output_chain_update_filters(struct mp_output_chain *c,
struct mp_user_filter *u = NULL;
for (int i = 0; i < p->num_user_filters; i++) {
- struct m_option t = {.type = &m_option_type_obj_settings_list};
- if (!used[i] && m_option_equal(&t, &entry, &p->user_filters[i]->args))
+ if (!used[i] && m_obj_settings_equal(entry, p->user_filters[i]->args))
{
u = p->user_filters[i];
used[i] = true;
diff --git a/options/m_option.c b/options/m_option.c
index c472b94d6f..874b22f6f4 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -2813,27 +2813,13 @@ static void obj_setting_free(m_obj_settings_t *item)
}
// If at least one item has a label, compare labels only - otherwise ignore them.
-static bool obj_setting_equals(m_obj_settings_t *a, m_obj_settings_t *b)
+static bool obj_setting_match(m_obj_settings_t *a, m_obj_settings_t *b)
{
bstr la = bstr0(a->label), lb = bstr0(b->label);
if (la.len || lb.len)
return bstr_equals(la, lb);
- if (strcmp(a->name, b->name) != 0)
- return false;
- int a_attr_count = 0;
- while (a->attribs && a->attribs[a_attr_count])
- a_attr_count++;
- int b_attr_count = 0;
- while (b->attribs && b->attribs[b_attr_count])
- b_attr_count++;
- if (a_attr_count != b_attr_count)
- return false;
- for (int n = 0; n < a_attr_count; n++) {
- if (strcmp(a->attribs[n], b->attribs[n]) != 0)
- return false;
- }
- return true;
+ return m_obj_settings_equal(a, b);
}
static int obj_settings_list_num_items(m_obj_settings_t *obj_list)
@@ -2898,7 +2884,7 @@ static int obj_settings_find_by_content(m_obj_settings_t *obj_list,
m_obj_settings_t *item)
{
for (int n = 0; obj_list && obj_list[n].name; n++) {
- if (obj_setting_equals(&obj_list[n], item))
+ if (obj_setting_match(&obj_list[n], item))
return n;
}
return -1;
@@ -3632,6 +3618,18 @@ static bool obj_settings_list_equal(const m_option_t *opt, void *pa, void *pb)
if (a == b || !a || !b)
return a == b;
+ for (int n = 0; a[n].name || b[n].name; n++) {
+ if (!a[n].name || !b[n].name)
+ return false;
+ if (!m_obj_settings_equal(&a[n], &b[n]))
+ return false;
+ }
+
+ return true;
+}
+
+bool m_obj_settings_equal(struct m_obj_settings *a, struct m_obj_settings *b)
+{
if (!str_equal(NULL, &a->name, &b->name))
return false;
diff --git a/options/m_option.h b/options/m_option.h
index 33cbe19986..06b9c53350 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -181,6 +181,8 @@ typedef struct m_obj_settings {
char **attribs;
} m_obj_settings_t;
+bool m_obj_settings_equal(struct m_obj_settings *a, struct m_obj_settings *b);
+
struct m_opt_choice_alternatives {
char *name;
int value;