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.
This commit is contained in:
wm4
2016-09-02 15:45:22 +02:00
parent f2e25e9e1f
commit 423e53ba0b
5 changed files with 264 additions and 5 deletions

View File

@@ -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;