summaryrefslogtreecommitdiffstats
path: root/options/m_config.h
diff options
context:
space:
mode:
Diffstat (limited to 'options/m_config.h')
-rw-r--r--options/m_config.h40
1 files changed, 20 insertions, 20 deletions
diff --git a/options/m_config.h b/options/m_config.h
index 1f6f5157a3..40cd367613 100644
--- a/options/m_config.h
+++ b/options/m_config.h
@@ -43,12 +43,10 @@ struct m_config_option {
bool is_set_from_config : 1; // Set by a config file
bool is_set_locally : 1; // Has a backup entry
bool warning_was_printed : 1;
- int16_t shadow_offset; // Offset into m_config_shadow.data
- int16_t group; // Index into m_config.groups
+ int16_t group_index; // Index into m_config.groups
const char *name; // Full name (ie option-subopt)
const struct m_option *opt; // Option description
void *data; // Raw value of the option
- const void *default_data; // Raw default value
};
// Config object
@@ -61,11 +59,6 @@ typedef struct m_config {
struct m_config_option *opts; // all options, even suboptions
int num_opts;
- // Creation parameters
- size_t size;
- const void *defaults;
- const struct m_option *options;
-
// List of defined profiles.
struct m_profile *profiles;
// Depth when recursively including profiles.
@@ -94,14 +87,17 @@ typedef struct m_config {
void *optstruct; // struct mpopts or other
- int shadow_size;
-
- // List of m_sub_options instances.
+ // Private. List of m_sub_options instances.
// Index 0 is the top-level and is always present.
+ // Immutable after init.
+ // Invariant: a parent is always at a lower index than any of its children.
struct m_config_group *groups;
int num_groups;
- // Thread-safe shadow memory; only set for the main m_config.
+ // Private. Non-NULL if data was allocated. m_config_option.data uses it.
+ struct m_config_data *data;
+
+ // Private. Thread-safe shadow memory; only set for the main m_config.
struct m_config_shadow *shadow;
} m_config_t;
@@ -182,6 +178,8 @@ struct m_config_option *m_config_get_co(const struct m_config *config,
int m_config_get_co_count(struct m_config *config);
struct m_config_option *m_config_get_co_index(struct m_config *config, int index);
+const void *m_config_get_co_default(const struct m_config *config,
+ struct m_config_option *co);
// Return the n-th option by position. n==0 is the first option. If there are
// less than (n + 1) options, return NULL.
@@ -264,14 +262,13 @@ struct mpv_node m_config_get_profiles(struct m_config *config);
// the cache itself is allowed.
struct m_config_cache {
// The struct as indicated by m_config_cache_alloc's group parameter.
+ // (Internally the same as data->gdata[0]->udata.)
void *opts;
// Internal.
- struct m_config_shadow *shadow;
- struct m_config *shadow_config;
- long long ts;
- int group;
- bool in_list;
+ struct m_config_shadow *shadow; // real data
+ struct m_config_data *data; // copy for the cache user
+ bool in_list; // registered as listener with root config
// --- Implicitly synchronized by setting/unsetting wakeup_cb.
struct mp_dispatch_queue *wakeup_dispatch_queue;
void (*wakeup_dispatch_cb)(void *ctx);
@@ -281,15 +278,17 @@ struct m_config_cache {
void *wakeup_cb_ctx;
};
+#define GLOBAL_CONFIG NULL
+
// Create a mirror copy from the global options.
// Keep in mind that a m_config_cache object is not thread-safe; it merely
// provides thread-safe access to the global options. All API functions for
// the same m_config_cache object must synchronized, unless otherwise noted.
// ta_parent: parent for the returned allocation
// global: option data source
-// group: the option group to return. This can be NULL for the global option
-// struct (MPOpts), or m_sub_options used in a certain OPT_SUBSTRUCT()
-// item.
+// group: the option group to return. This can be GLOBAL_CONFIG for the global
+// option struct (MPOpts), or m_sub_options used in a certain
+// OPT_SUBSTRUCT() item.
struct m_config_cache *m_config_cache_alloc(void *ta_parent,
struct mpv_global *global,
const struct m_sub_options *group);
@@ -320,6 +319,7 @@ bool m_config_cache_update(struct m_config_cache *cache);
// Like m_config_cache_alloc(), but return the struct (m_config_cache->opts)
// directly, with no way to update the config. Basically this returns a copy
// with a snapshot of the current option values.
+// group==GLOBAL_CONFIG is a special case, and always returns the root group.
void *mp_get_config_group(void *ta_parent, struct mpv_global *global,
const struct m_sub_options *group);