From d26b5daf3ed32136540d39614afe7ef631a1319f Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 4 Jan 2020 21:12:29 +0100 Subject: command: make sub-step command actually apply sub-delay change properly The change was not propagated to the OSD/subtitle code, since that still uses an "old" method. Change it so that the propagation is actually performed. (One could argue the OSD/subtitle code should use other ways to update the options, but that would probably be more effort for now.) --- options/m_config.c | 16 ++++++++++++++-- options/m_config.h | 4 ++++ player/command.c | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/options/m_config.c b/options/m_config.c index 968999cb71..00557c5673 100644 --- a/options/m_config.c +++ b/options/m_config.c @@ -1000,13 +1000,13 @@ static void force_self_notify_change_opt(struct m_config *config, } } -void m_config_notify_change_opt_ptr(struct m_config *config, void *ptr) +static void notify_opt(struct m_config *config, void *ptr, bool self_notification) { for (int n = 0; n < config->num_opts; n++) { struct m_config_option *co = &config->opts[n]; if (co->data == ptr) { if (m_config_cache_write_opt(config->cache, co->data)) - force_self_notify_change_opt(config, co, true); + force_self_notify_change_opt(config, co, self_notification); return; } } @@ -1015,6 +1015,18 @@ void m_config_notify_change_opt_ptr(struct m_config *config, void *ptr) assert(false); } +void m_config_notify_change_opt_ptr(struct m_config *config, void *ptr) +{ + notify_opt(config, ptr, true); +} + +void m_config_notify_change_opt_ptr_notify(struct m_config *config, void *ptr) +{ + // (the notify bool is inverted: by not marking it as self-notification, + // the mpctx option change handler actually applies it) + notify_opt(config, ptr, false); +} + int m_config_set_option_raw(struct m_config *config, struct m_config_option *co, void *data, int flags) diff --git a/options/m_config.h b/options/m_config.h index 25d26e05ee..862d40c3a3 100644 --- a/options/m_config.h +++ b/options/m_config.h @@ -196,6 +196,10 @@ int m_config_option_requires_param(struct m_config *config, bstr name); // This will force a self-notification back to config->option_change_callback. void m_config_notify_change_opt_ptr(struct m_config *config, void *ptr); +// Exactly like m_config_notify_change_opt_ptr(), but the option change callback +// (config->option_change_callback()) is invoked with self_update=false, if at all. +void m_config_notify_change_opt_ptr_notify(struct m_config *config, void *ptr); + // Return all (visible) option names as NULL terminated string list. char **m_config_list_options(void *ta_parent, const struct m_config *config); diff --git a/player/command.c b/player/command.c index 0a17a1def4..f95762395a 100644 --- a/player/command.c +++ b/player/command.c @@ -4732,7 +4732,7 @@ static void cmd_sub_step_seek(void *p) if (sub_control(sub, SD_CTRL_SUB_STEP, a) > 0) { if (step) { mpctx->opts->subs_rend->sub_delay -= a[0] - refpts; - m_config_notify_change_opt_ptr(mpctx->mconfig, + m_config_notify_change_opt_ptr_notify(mpctx->mconfig, &mpctx->opts->subs_rend->sub_delay); show_property_osd(mpctx, "sub-delay", cmd->on_osd); } else { -- cgit v1.2.3