summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-17 20:48:22 +0200
committerwm4 <wm4@nowhere>2016-09-17 20:48:22 +0200
commita3e8ff624c8adf3b18dddea0fdede7b7fa8c4eb1 (patch)
treeb5ed419e0ea57138e584e560c17cecb207d49364 /options
parent2d34171bec55294375e57f8bea86e2dee153d2cc (diff)
downloadmpv-a3e8ff624c8adf3b18dddea0fdede7b7fa8c4eb1.tar.bz2
mpv-a3e8ff624c8adf3b18dddea0fdede7b7fa8c4eb1.tar.xz
options: take care of propertly updating options on runtime changes
All option write accesses are now put through the property interface, which means runtime option value verification and runtime updates are applied. This is done even for command line arguments and config files. This has many subtle and not-so-subtle consequences. The potential for unintended and intended subtle or not-subtle behavior changes is very large. Architecturally, this is us literally jumping through hoops. It really should work the other way around, with options being able to have callbacks for value verification and applying runtime updates. But this would require rewriting the entirety of command.c. This change is more practical, and if anything will at least allow incremental changes. Some options are too incompatible for this to work - these are excluded with an explicit blacklist. This change fixes many issues caused by the mismatch between properties and options. For example, this fixes #3281.
Diffstat (limited to 'options')
-rw-r--r--options/m_config.c26
-rw-r--r--options/m_config.h10
2 files changed, 31 insertions, 5 deletions
diff --git a/options/m_config.c b/options/m_config.c
index c6c1bf9af1..7cc9a46792 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -676,9 +676,11 @@ static int handle_set_opt_flags(struct m_config *config,
return set ? 2 : 1;
}
-// 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)
+// Unlike m_config_set_option_raw() this does not go through the property layer
+// via config.option_set_callback.
+int m_config_set_option_raw_direct(struct m_config *config,
+ struct m_config_option *co,
+ void *data, int flags)
{
if (!co)
return M_OPT_UNKNOWN;
@@ -702,6 +704,24 @@ int m_config_set_option_raw(struct m_config *config, struct m_config_option *co,
return 0;
}
+// Similar to m_config_set_option_ext(), but set as data in its native format.
+// This takes care of some details like sending change notifications.
+// 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)
+{
+ if (config->option_set_callback) {
+ int r = handle_set_opt_flags(config, co, flags);
+ if (r <= 1)
+ return r;
+
+ return config->option_set_callback(config->option_set_callback_cb,
+ co, data, flags);
+ } else {
+ return m_config_set_option_raw_direct(config, co, data, flags);
+ }
+}
+
static int parse_subopts(struct m_config *config, char *name, char *prefix,
struct bstr param, int flags);
diff --git a/options/m_config.h b/options/m_config.h
index e7c095623b..9440bd5833 100644
--- a/options/m_config.h
+++ b/options/m_config.h
@@ -77,6 +77,10 @@ typedef struct m_config {
int (*includefunc)(void *ctx, char *filename, int flags);
void *includefunc_ctx;
+ int (*option_set_callback)(void *ctx, struct m_config_option *co,
+ void *data, int flags);
+ void *option_set_callback_cb;
+
// For the command line parser
int recursion_depth;
@@ -170,11 +174,13 @@ static inline int m_config_set_option0(struct m_config *config,
return m_config_set_option(config, bstr0(name), bstr0(param));
}
-// Similar to m_config_set_option_ext(), but set as data in its native format.
-// 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);
+int m_config_set_option_raw_direct(struct m_config *config,
+ struct m_config_option *co,
+ void *data, int flags);
+
// Similar to m_config_set_option_ext(), but set as data using mpv_node.
struct mpv_node;
int m_config_set_option_node(struct m_config *config, bstr name,