summaryrefslogtreecommitdiffstats
path: root/options/m_config.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-11-29 12:49:15 +0100
committerwm4 <wm4@nowhere>2019-11-29 12:49:15 +0100
commitb16cea750f527088be79772e7cd601f86ce62ef2 (patch)
tree7bca2775a35f501baacafdbab63060d95ec99469 /options/m_config.h
parent5e2658c98196f8fd3558a2ffe40bd789ed27e8a3 (diff)
downloadmpv-b16cea750f527088be79772e7cd601f86ce62ef2.tar.bz2
mpv-b16cea750f527088be79772e7cd601f86ce62ef2.tar.xz
player: change m_config to use new option handling mechanisms
Instead of making m_config a special-case, it more or less uses the underlying m_config_cache/m_config_shadow APIs properly. This makes the player core a (relatively) equivalent user of the core option API. In particular, this means that other threads can change core options with m_config_cache_write_opt() calls (before this commit, this merely led to diverging option values). An important change is that before this commit, mpctx->opts contained the "master copy" of all option data. Now it's just another copy of the option data, and the shadow copy is considered the master. This is why whenever mpctx->opts is written, the change needs to be copied to the master (thus why this commits add a bunch of m_config_notify... calls). If another thread (e.g. a VO) changes an option, async_change_cb is now invoked, which funnels the change notification through the player's layers. The new self_notification parameter on mp_option_change_callback is so that m_config_notify... doesn't trigger recursion, and it's used in cases where the change was already "processed". It's still needed to trigger libmpv property updates. (I considered using an extra m_config_cache for that, but it'd only cause problems with no advantages.) I think the recent changes actually forgot to send libmpv property updates in some cases. This should fix this anyway. In some cases, property updates are reworked, and the potential for bugs should be lower (probably). The primary point of this change is to allow external updates, for example by a VO writing the fullscreen option if the window state is changed by the window manager (rather than mpv changing it). This is not used yet, but the following commits will.
Diffstat (limited to 'options/m_config.h')
-rw-r--r--options/m_config.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/options/m_config.h b/options/m_config.h
index f62bc9670f..25d26e05ee 100644
--- a/options/m_config.h
+++ b/options/m_config.h
@@ -74,8 +74,11 @@ typedef struct m_config {
// Notification after an option was successfully written to.
// Uses flags as set in UPDATE_OPTS_MASK.
+ // self_update==true means the update was caused by a call to
+ // m_config_notify_change_opt_ptr(). If false, it's caused either by
+ // m_config_set_option_*() (and similar) calls or external updates.
void (*option_change_callback)(void *ctx, struct m_config_option *co,
- int flags);
+ int flags, bool self_update);
void *option_change_callback_ctx;
// For the command line parser
@@ -84,7 +87,8 @@ typedef struct m_config {
void *optstruct; // struct mpopts or other
// Private. Non-NULL if data was allocated. m_config_option.data uses it.
- struct m_config_data *data;
+ // API users call m_config_set_update_dispatch_queue() to get async updates.
+ struct m_config_cache *cache;
// Private. Thread-safe shadow memory; only set for the main m_config.
struct m_config_shadow *shadow;
@@ -189,11 +193,7 @@ const char *m_config_get_positional_option(const struct m_config *config, int n)
int m_config_option_requires_param(struct m_config *config, bstr name);
// Notify m_config_cache users that the option has (probably) changed its value.
-void m_config_notify_change_co(struct m_config *config,
- struct m_config_option *co);
-// Like m_config_notify_change_co(), but automatically find the option by its
-// pointer within the global option struct (config->optstruct). In practice,
-// it means it works only on fields in MPContext.opts.
+// 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);
// Return all (visible) option names as NULL terminated string list.
@@ -253,6 +253,10 @@ int m_config_set_profile(struct m_config *config, char *name, int flags);
struct mpv_node m_config_get_profiles(struct m_config *config);
+// Run async option updates here. This will call option_change_callback() on it.
+void m_config_set_update_dispatch_queue(struct m_config *config,
+ struct mp_dispatch_queue *dispatch);
+
// This can be used to create and synchronize per-thread option structs,
// which then can be read without synchronization. No concurrent access to
// the cache itself is allowed.