summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-02 15:45:22 +0200
committerwm4 <wm4@nowhere>2016-09-02 15:50:40 +0200
commit423e53ba0bad034685e5229720d55548afb1efbe (patch)
tree08c8ed2d32f7c7ed88b3d468d09249adec6017ee /player
parentf2e25e9e1f5aa28689d152d7a7cb4c39bdac9c82 (diff)
downloadmpv-423e53ba0bad034685e5229720d55548afb1efbe.tar.bz2
mpv-423e53ba0bad034685e5229720d55548afb1efbe.tar.xz
m_config: introduce basic mechanism to synchronize global option updates
The way option runtime changes are handled is pretty bad in the current codebase. There's a big option struct (MPOpts), which contains almost everything, and for which no synchronization mechanism exists. This was handled by either making some options read-only after initialization, duplicating the option struct, using sub-options (in the VO), and so on. Introduce a mechanism that creates a copy of the global options (or parts of it), and provides a well-defined way to update them in a thread-safe way. Most code can remain the same, just that all the component glue code has to explicitly make use of it first. There is still lots of room for improvement. For example, the update mechanism could be better.
Diffstat (limited to 'player')
-rw-r--r--player/main.c1
-rw-r--r--player/misc.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/player/main.c b/player/main.c
index 6acb617520..b60c522cb0 100644
--- a/player/main.c
+++ b/player/main.c
@@ -364,6 +364,7 @@ struct MPContext *mp_create(void)
mpctx->mconfig->is_toplevel = true;
mpctx->mconfig->global = mpctx->global;
m_config_parse(mpctx->mconfig, "", bstr0(def_config), NULL, 0);
+ m_config_create_shadow(mpctx->mconfig);
mpctx->global->opts = mpctx->opts;
diff --git a/player/misc.c b/player/misc.c
index 489eceb6a3..62223ebfef 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -261,6 +261,7 @@ struct mpv_global *create_sub_global(struct MPContext *mpctx)
struct m_config *new_config = m_config_dup(new, mpctx->mconfig);
*new = (struct mpv_global){
.log = mpctx->global->log,
+ .config = mpctx->global->config,
.opts = new_config->optstruct,
.client_api = mpctx->clients,
};