summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-17 17:47:22 +0200
committerwm4 <wm4@nowhere>2016-09-17 17:47:22 +0200
commitd1d5e9dda430b2aa7172308ad7c6639913680af5 (patch)
treef77e95f37293adbb6a0ac5cb9ad44f988cc10c8d /options
parent7fa26bfd9c2c927e8f90089f2fe1822c72ea11d0 (diff)
downloadmpv-d1d5e9dda430b2aa7172308ad7c6639913680af5.tar.bz2
mpv-d1d5e9dda430b2aa7172308ad7c6639913680af5.tar.xz
m_config: make option setting always call m_config_set_option_raw()
This makes m_config_set_option_raw() the function that is always called on the lowest level (as leaf function for all other functions). To do this, m_config_parse_option() has to do something special to deal with "impure" options like --vf-add, which work on the previous option value, instead of fully replacing it. m_config_set_option_raw() itself always completely replaced the previous value.
Diffstat (limited to 'options')
-rw-r--r--options/m_config.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/options/m_config.c b/options/m_config.c
index 25c72ede9b..2bc187b444 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -373,7 +373,8 @@ void m_config_restore_backups(struct m_config *config)
struct m_opt_backup *bc = config->backup_opts;
config->backup_opts = bc->next;
- m_option_copy(bc->co->opt, bc->co->data, bc->backup);
+ m_config_set_option_raw(config, bc->co, bc->backup, 0);
+
m_option_free(bc->co->opt, bc->backup);
bc->co->is_set_locally = false;
talloc_free(bc);
@@ -675,15 +676,6 @@ static int handle_set_opt_flags(struct m_config *config,
return set ? 2 : 1;
}
-static void handle_on_set(struct m_config *config, struct m_config_option *co,
- int flags)
-{
- if (flags & M_SETOPT_FROM_CMDLINE)
- co->is_set_from_cmdline = true;
-
- m_config_notify_change_co(config, co);
-}
-
// The type data points to is as in: co->opt
int m_config_set_option_raw(struct m_config *config, struct m_config_option *co,
void *data, int flags)
@@ -701,7 +693,12 @@ int m_config_set_option_raw(struct m_config *config, struct m_config_option *co,
return r;
m_option_copy(co->opt, co->data, data);
- handle_on_set(config, co, flags);
+
+ if (flags & M_SETOPT_FROM_CMDLINE)
+ co->is_set_from_cmdline = true;
+
+ m_config_notify_change_co(config, co);
+
return 0;
}
@@ -784,10 +781,19 @@ static int m_config_parse_option(struct m_config *config, struct bstr name,
return parse_subopts(config, (char *)co->name, prefix, param, flags);
}
- r = m_option_parse(config->log, co->opt, name, param, set ? co->data : NULL);
+ union m_option_value val = {0};
+
+ // Some option tpyes are "impure" and work on the existing data.
+ // (Prime examples: --vf-add, --sub-file)
+ if (co->data)
+ m_option_copy(co->opt, &val, co->data);
- if (r >= 0 && set)
- handle_on_set(config, co, flags);
+ r = m_option_parse(config->log, co->opt, name, param, &val);
+
+ if (r >= 0)
+ r = m_config_set_option_raw(config, co, &val, flags);
+
+ m_option_free(co->opt, &val);
return r;
}