summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-25 20:25:20 +0100
committerwm4 <wm4@nowhere>2019-11-25 20:29:43 +0100
commit7c6570402bb203a1f1deb5b76807a9c021f47e82 (patch)
tree3e1e8411dba9fe8469ca9c9aedddb6721b59cb33
parent78bb1586d34bcd0cf89267d9447a9cef6ef29761 (diff)
downloadmpv-7c6570402bb203a1f1deb5b76807a9c021f47e82.tar.bz2
mpv-7c6570402bb203a1f1deb5b76807a9c021f47e82.tar.xz
options: remove options-to-property bridge
The previous bunch of commits made this unnecessary, so this should be a purely internal change with no user impact. This may or may not open the way to future improvements. Even if not, at least the property/option interaction should now be much less buggy.
-rw-r--r--options/m_config.c24
-rw-r--r--options/m_config.h11
-rw-r--r--player/command.c51
-rw-r--r--player/command.h1
-rw-r--r--player/main.c2
-rw-r--r--player/playloop.c2
6 files changed, 6 insertions, 85 deletions
diff --git a/options/m_config.c b/options/m_config.c
index 3fe8a67235..46b67a774f 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -814,9 +814,9 @@ static int m_config_handle_special_options(struct m_config *config,
return M_OPT_UNKNOWN;
}
-int m_config_set_option_raw_direct(struct m_config *config,
- struct m_config_option *co,
- void *data, int flags)
+int m_config_set_option_raw(struct m_config *config,
+ struct m_config_option *co,
+ void *data, int flags)
{
if (!co)
return M_OPT_UNKNOWN;
@@ -842,24 +842,6 @@ int m_config_set_option_raw_direct(struct m_config *config,
return 0;
}
-int m_config_set_option_raw(struct m_config *config, struct m_config_option *co,
- void *data, int flags)
-{
- if (!co)
- return M_OPT_UNKNOWN;
-
- 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);
- }
-}
-
// Handle CLI exceptions to option handling.
// Used to turn "--no-foo" into "--foo=no".
// It also handles looking up "--vf-add" as "--vf".
diff --git a/options/m_config.h b/options/m_config.h
index a897ca053b..120a82b768 100644
--- a/options/m_config.h
+++ b/options/m_config.h
@@ -71,11 +71,6 @@ typedef struct m_config {
int (*includefunc)(void *ctx, char *filename, int flags);
void *includefunc_ctx;
- // Can intercept option write accesses.
- int (*option_set_callback)(void *ctx, struct m_config_option *co,
- void *data, int flags);
- void *option_set_callback_cb;
-
// Notification after an option was successfully written to.
// Uses flags as set in UPDATE_OPTS_MASK.
void (*option_change_callback)(void *ctx, struct m_config_option *co,
@@ -169,12 +164,6 @@ int m_config_set_option_raw(struct m_config *config, struct m_config_option *co,
void m_config_mark_co_flags(struct m_config_option *co, 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);
-
// Convert the mpv_node to raw option data, then call m_config_set_option_raw().
struct mpv_node;
int m_config_set_option_node(struct m_config *config, bstr name,
diff --git a/player/command.c b/player/command.c
index 744f87abd9..cd8a7959c8 100644
--- a/player/command.c
+++ b/player/command.c
@@ -374,53 +374,6 @@ static char *format_delay(double time)
return talloc_asprintf(NULL, "%d ms", (int)lrint(time * 1000));
}
-// Option-property bridge. This is used so that setting options via various
-// mechanisms (including command line parsing, config files, per-file options)
-// updates state associated with them. For that, they have to go through the
-// property layer. (Ideally, this would be the other way around, and there
-// would be per-option change handlers instead.)
-// Note that the property-option bridge sidesteps this, as we'd get infinite
-// recursion.
-int mp_on_set_option(void *ctx, struct m_config_option *co, void *data, int flags)
-{
- struct MPContext *mpctx = ctx;
- struct command_ctx *cmd = mpctx->command_ctx;
- const char *name = co->name;
-
- // Skip going through mp_property_generic_option (typically), because the
- // property implementation is trivial, and can break some obscure features
- // like --profile and --include if non-trivial flags are involved (which
- // the bridge would drop).
- struct m_property *prop = m_property_list_find(cmd->properties, name);
- if (prop && prop->is_option)
- goto direct_option;
-
- struct m_option type = {0};
-
- int r = mp_property_do_silent(name, M_PROPERTY_GET_TYPE, &type, mpctx);
- if (r == M_PROPERTY_UNKNOWN)
- goto direct_option; // not mapped as property
- if (r != M_PROPERTY_OK)
- return M_OPT_INVALID; // shouldn't happen
-
- assert(type.type == co->opt->type);
- assert(type.max == co->opt->max);
- assert(type.min == co->opt->min);
-
- r = mp_property_do_silent(name, M_PROPERTY_SET, data, mpctx);
- if (r != M_PROPERTY_OK)
- return M_OPT_INVALID;
-
- // The flags can't be passed through the property layer correctly.
- m_config_mark_co_flags(co, flags);
-
- return 0;
-
-direct_option:
- mp_notify_property(mpctx, name);
- return m_config_set_option_raw_direct(mpctx->mconfig, co, data, flags);
-}
-
// Property-option bridge. (Maps the property to the option with the same name.)
static int mp_property_generic_option(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -448,7 +401,7 @@ static int mp_property_generic_option(void *ctx, struct m_property *prop,
m_option_copy(opt->opt, arg, opt->data);
return M_PROPERTY_OK;
case M_PROPERTY_SET:
- if (m_config_set_option_raw_direct(mpctx->mconfig, opt, arg, 0) < 0)
+ if (m_config_set_option_raw(mpctx->mconfig, opt, arg, 0) < 0)
return M_PROPERTY_ERROR;
return M_PROPERTY_OK;
}
@@ -2643,7 +2596,7 @@ skip_warn: ;
return M_PROPERTY_OK;
}
case M_PROPERTY_SET:
- if (m_config_set_option_raw_direct(mpctx->mconfig, opt, arg, 0) < 0)
+ if (m_config_set_option_raw(mpctx->mconfig, opt, arg, 0) < 0)
return M_PROPERTY_ERROR;
return M_PROPERTY_OK;
}
diff --git a/player/command.h b/player/command.h
index 3952ce37e7..037dec1164 100644
--- a/player/command.h
+++ b/player/command.h
@@ -78,7 +78,6 @@ void property_print_help(struct MPContext *mpctx);
int mp_property_do(const char* name, int action, void* val,
struct MPContext *mpctx);
-int mp_on_set_option(void *ctx, struct m_config_option *co, void *data, int flags);
void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags);
void mp_notify(struct MPContext *mpctx, int event, void *arg);
diff --git a/player/main.c b/player/main.c
index d633871399..3f39dad04c 100644
--- a/player/main.c
+++ b/player/main.c
@@ -378,8 +378,6 @@ int mp_initialize(struct MPContext *mpctx, char **options)
// From this point on, all mpctx members are initialized.
mpctx->initialized = true;
- mpctx->mconfig->option_set_callback = mp_on_set_option;
- mpctx->mconfig->option_set_callback_cb = mpctx;
mpctx->mconfig->option_change_callback = mp_option_change_callback;
mpctx->mconfig->option_change_callback_ctx = mpctx;
// Run all update handlers.
diff --git a/player/playloop.c b/player/playloop.c
index 907a732a01..5c83615a86 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -844,7 +844,7 @@ static void handle_vo_events(struct MPContext *mpctx)
int fs = old_fs;
vo_control(vo, VOCTRL_GET_FULLSCREEN, &fs);
if (old_fs != fs) {
- m_config_set_option_raw_direct(mpctx->mconfig,
+ m_config_set_option_raw(mpctx->mconfig,
m_config_get_co(mpctx->mconfig, bstr0("fullscreen")), &fs, 0);
}
}