diff options
Diffstat (limited to 'options/m_config_frontend.c')
-rw-r--r-- | options/m_config_frontend.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/options/m_config_frontend.c b/options/m_config_frontend.c index a3356c4111..0506bcbfb3 100644 --- a/options/m_config_frontend.c +++ b/options/m_config_frontend.c @@ -244,6 +244,26 @@ void m_config_restore_backups(struct m_config *config) restore_backups(&config->backup_opts, config); } +bool m_config_watch_later_backup_opt_changed(struct m_config *config, + char *opt_name) +{ + struct m_config_option *co = m_config_get_co(config, bstr0(opt_name)); + if (!co) { + MP_ERR(config, "Option %s not found.\n", opt_name); + return false; + } + + for (struct m_opt_backup *bc = config->watch_later_backup_opts; bc; + bc = bc->next) { + if (strcmp(bc->co->name, co->name) == 0) { + struct m_config_option *bc_co = (struct m_config_option *)bc->backup; + return !m_option_equal(co->opt, co->data, bc_co); + } + } + + return false; +} + void m_config_backup_opt(struct m_config *config, const char *opt) { struct m_config_option *co = m_config_get_co(config, bstr0(opt)); @@ -260,6 +280,11 @@ void m_config_backup_all_opts(struct m_config *config) ensure_backup(&config->backup_opts, BACKUP_LOCAL, &config->opts[n]); } +void m_config_backup_watch_later_opts(struct m_config *config) +{ + for (int n = 0; n < config->num_opts; n++) + ensure_backup(&config->watch_later_backup_opts, 0, &config->opts[n]); +} struct m_config_option *m_config_get_co_raw(const struct m_config *config, struct bstr name) @@ -509,6 +534,13 @@ static void config_destroy(void *p) config->option_change_callback = NULL; m_config_restore_backups(config); + struct m_opt_backup **list = &config->watch_later_backup_opts; + while (*list) { + struct m_opt_backup *bc = *list; + *list = bc->next; + talloc_free(bc); + } + talloc_free(config->cache); talloc_free(config->shadow); } @@ -826,7 +858,7 @@ void m_config_print_option_list(const struct m_config *config, const char *name) MP_INFO(config, " %s%-30s", prefix, co->name); if (opt->type == &m_option_type_choice) { MP_INFO(config, " Choices:"); - struct m_opt_choice_alternatives *alt = opt->priv; + const struct m_opt_choice_alternatives *alt = opt->priv; for (int n = 0; alt[n].name; n++) MP_INFO(config, " %s", alt[n].name); if (opt->min < opt->max) |