summaryrefslogtreecommitdiffstats
path: root/options/m_config.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-19 19:51:26 +0200
committerwm4 <wm4@nowhere>2016-09-19 19:51:26 +0200
commitfe7db610355b623305d08135869b3f4ff4487b6d (patch)
tree563523768617c50b6f41639b0fdc8550871da5c0 /options/m_config.c
parent32f235bcef49b268126262f45637b6818767f065 (diff)
downloadmpv-fe7db610355b623305d08135869b3f4ff4487b6d.tar.bz2
mpv-fe7db610355b623305d08135869b3f4ff4487b6d.tar.xz
options: slightly better option update mechanism
Extend the flag-based notification mechanism that was used via M_OPT_TERM. Make the vo_opengl update mechanism use this (which, btw., also fixes compilation with OpenGL renderers forcibly disabled). While this adds a 3rd mechanism and just seems to further the chaos, I'd rather have a very simple mechanism now, than actually furthering the mess by mixing old and new update mechanisms. In particular, we'll be able to remove quite some property implementations, and replace them with much simpler update handling. The new update mechanism can also more easily refactored once we have a final mechanism that handles everything in an uniform way.
Diffstat (limited to 'options/m_config.c')
-rw-r--r--options/m_config.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/options/m_config.c b/options/m_config.c
index 6dd72380d9..4659c9aa21 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -418,6 +418,9 @@ static void add_sub_options(struct m_config *config,
for (int n = 0; n < config->num_groups; n++)
assert(config->groups[n].group != subopts);
+ // You can only use UPDATE_ flags here.
+ assert(!(subopts->change_flags & ~(unsigned)UPDATE_OPTS_MASK));
+
void *new_optstruct = NULL;
if (config->optstruct) { // only if not noalloc
new_optstruct = talloc_zero_size(config, subopts->size);
@@ -1255,16 +1258,23 @@ void m_config_notify_change_co(struct m_config *config,
if (co->shadow_offset >= 0)
m_option_copy(co->opt, shadow->data + co->shadow_offset, co->data);
pthread_mutex_unlock(&shadow->lock);
+ }
- int group = co->group;
- while (group >= 0) {
- atomic_fetch_add(&config->groups[group].ts, 1);
- group = config->groups[group].parent_group;
- }
+ int changed = co->opt->flags & UPDATE_OPTS_MASK;
+
+ int group = co->group;
+ while (group >= 0) {
+ struct m_config_group *g = &config->groups[group];
+ atomic_fetch_add(&g->ts, 1);
+ if (g->group)
+ changed |= g->group->change_flags;
+ group = g->parent_group;
}
- if (config->global && (co->opt->flags & M_OPT_TERM))
- mp_msg_update_msglevels(config->global);
+ if (config->option_change_callback) {
+ config->option_change_callback(config->option_change_callback_ctx, co,
+ changed);
+ }
}
bool m_config_is_in_group(struct m_config *config,