diff options
author | wm4 <wm4@nowhere> | 2019-11-25 20:25:20 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2019-11-25 20:29:43 +0100 |
commit | 7c6570402bb203a1f1deb5b76807a9c021f47e82 (patch) | |
tree | 3e1e8411dba9fe8469ca9c9aedddb6721b59cb33 /player | |
parent | 78bb1586d34bcd0cf89267d9447a9cef6ef29761 (diff) | |
download | mpv-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.
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 51 | ||||
-rw-r--r-- | player/command.h | 1 | ||||
-rw-r--r-- | player/main.c | 2 | ||||
-rw-r--r-- | player/playloop.c | 2 |
4 files changed, 3 insertions, 53 deletions
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); } } |