From 423e53ba0bad034685e5229720d55548afb1efbe Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 2 Sep 2016 15:45:22 +0200 Subject: 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. --- common/global.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/global.h b/common/global.h index fb70b4ff01..879ca72386 100644 --- a/common/global.h +++ b/common/global.h @@ -5,9 +5,13 @@ // The only purpose of this is to make mpv library-safe. // Think hard before adding new members. struct mpv_global { - struct MPOpts *opts; struct mp_log *log; + struct m_config_shadow *config; struct mp_client_api *client_api; + + // Using this is deprecated and should be avoided (missing synchronization). + // Use m_config_cache to access mpv_global.config instead. + struct MPOpts *opts; }; #endif -- cgit v1.2.3