summaryrefslogtreecommitdiffstats
path: root/options
diff options
context:
space:
mode:
Diffstat (limited to 'options')
-rw-r--r--options/m_config.c24
-rw-r--r--options/m_config.h7
-rw-r--r--options/m_option.h17
-rw-r--r--options/options.c14
4 files changed, 45 insertions, 17 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,
diff --git a/options/m_config.h b/options/m_config.h
index 8befc51805..74390f150b 100644
--- a/options/m_config.h
+++ b/options/m_config.h
@@ -77,10 +77,17 @@ typedef struct m_config {
int (*includefunc)(void *ctx, char *filename, int flags);
void *includefunc_ctx;
+ // Can intercept option write accesses.
int (*option_set_callback)(void *ctx, struct m_config_option *co,
void *data, int flags);
void *option_set_callback_cb;
+ // Notification after an option was successfully written to.
+ // Uses flags as set in UPDATE_OPTS_MASK.
+ void (*option_change_callback)(void *ctx, struct m_config_option *co,
+ int flags);
+ void *option_change_callback_ctx;
+
// For the command line parser
int recursion_depth;
diff --git a/options/m_option.h b/options/m_option.h
index 6435584716..a47bbaa7d7 100644
--- a/options/m_option.h
+++ b/options/m_option.h
@@ -191,6 +191,9 @@ struct m_sub_options {
const struct m_option *opts;
size_t size;
const void *defaults;
+ // Change flags passed to mp_option_change_callback() if any option that is
+ // directly or indirectly part of this group is changed.
+ int change_flags;
};
#define CONF_TYPE_FLAG (&m_option_type_flag)
@@ -372,12 +375,20 @@ struct m_option {
// The option expects a file name (or a list of file names)
#define M_OPT_FILE (1 << 11)
-// Logging-related option - used to update log/terminal settings eagerly
-#define M_OPT_TERM (1 << 12)
-
// Do not add as property.
#define M_OPT_NOPROP (1 << 13)
+// The following are also part of the M_OPT_* flags, and are used to update
+// certain groups of options.
+#define UPDATE_OPT_FIRST (1 << 14)
+#define UPDATE_TERM (1 << 14) // terminal options
+#define UPDATE_RENDERER (1 << 15) // mainly vo_opengl options
+#define UPDATE_OPT_LAST (1 << 15)
+
+// All bits between _FIRST and _LAST (inclusive)
+#define UPDATE_OPTS_MASK \
+ (((UPDATE_OPT_LAST << 1) - 1) & ~(unsigned)(UPDATE_OPT_FIRST - 1))
+
// These are kept for compatibility with older code.
#define CONF_MIN M_OPT_MIN
#define CONF_MAX M_OPT_MAX
diff --git a/options/options.c b/options/options.c
index 631d108119..88af4a1d8b 100644
--- a/options/options.c
+++ b/options/options.c
@@ -256,14 +256,14 @@ const m_option_t mp_opts[] = {
OPT_FLAG("quiet", quiet, 0),
OPT_FLAG_STORE("really-quiet", verbose,
CONF_GLOBAL | CONF_PRE_PARSE | M_OPT_NOPROP, -10),
- OPT_FLAG("terminal", use_terminal, CONF_GLOBAL | CONF_PRE_PARSE | M_OPT_TERM),
- OPT_GENERAL(char**, "msg-level", msg_levels, CONF_PRE_PARSE | M_OPT_TERM,
+ OPT_FLAG("terminal", use_terminal, CONF_GLOBAL | CONF_PRE_PARSE | UPDATE_TERM),
+ OPT_GENERAL(char**, "msg-level", msg_levels, CONF_PRE_PARSE | UPDATE_TERM,
.type = &m_option_type_msglevels),
- OPT_STRING("dump-stats", dump_stats, CONF_GLOBAL | CONF_PRE_PARSE),
- OPT_FLAG("msg-color", msg_color, CONF_PRE_PARSE | M_OPT_TERM),
- OPT_STRING("log-file", log_file, CONF_PRE_PARSE | M_OPT_FILE),
- OPT_FLAG("msg-module", msg_module, M_OPT_TERM),
- OPT_FLAG("msg-time", msg_time, M_OPT_TERM),
+ OPT_STRING("dump-stats", dump_stats, UPDATE_TERM | CONF_PRE_PARSE),
+ OPT_FLAG("msg-color", msg_color, CONF_PRE_PARSE | UPDATE_TERM),
+ OPT_STRING("log-file", log_file, CONF_PRE_PARSE | M_OPT_FILE | UPDATE_TERM),
+ OPT_FLAG("msg-module", msg_module, UPDATE_TERM),
+ OPT_FLAG("msg-time", msg_time, UPDATE_TERM),
#ifdef _WIN32
OPT_CHOICE("priority", w32_priority, CONF_GLOBAL,
({"no", 0},