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.)
This commit is contained in:
wm4 2020-01-04 21:12:29 +01:00
parent 1b0129c414
commit d26b5daf3e
3 changed files with 19 additions and 3 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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 {