mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user