From 4cae19237758a21685c9d988d24dafac713f3a30 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Nov 2019 23:49:23 +0100 Subject: options: remove M_OPT_FIXED Options marked with this flag were changed to strictly read-only after initialization (mpv_initialize() in the client API, after option parsing and config file loading with the CLI player). This used to be necessary, because there was a single option struct that could be accessed by multiple threads. For example, --config-dir sets MPOpts.force_configdir, which was read whenever anything accessed the mpv config dir (which could be on different threads, e.g. font initialization tries to lookup fonts.conf from an arbitrary thread). This isn't needed anymore, because threads now access these in a thread safe way. In the case of --config-dir, the path is actually just copied on init. This M_OPT_FIXED mechanism is thus not strictly needed anymore. It still prevents writing to some options that cannot take effect at runtime, but even that can be dropped. In general, all mpv options can be changed any time at runtime, even if they never take effect, and there's no need to make an exception for a very low number of options. So just get rid of it. --- options/options.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'options/options.c') diff --git a/options/options.c b/options/options.c index 53cf82abd8..d8d4c015d7 100644 --- a/options/options.c +++ b/options/options.c @@ -320,39 +320,38 @@ const struct m_sub_options filter_conf = { const m_option_t mp_opts[] = { // handled in command line pre-parser (parse_commandline.c) - {"v", &m_option_type_dummy_flag, M_OPT_FIXED | CONF_NOCFG | M_OPT_NOPROP, + {"v", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_NOPROP, .offset = -1}, - {"playlist", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN | M_OPT_FIXED | M_OPT_FILE, + {"playlist", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_MIN | M_OPT_FILE, .min = 1, .offset = -1}, - {"{", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP, + {"{", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_NOPROP, .offset = -1}, - {"}", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP, + {"}", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_NOPROP, .offset = -1}, // handled in m_config.c { "include", CONF_TYPE_STRING, M_OPT_FILE, .offset = -1}, { "profile", CONF_TYPE_STRING_LIST, 0, .offset = -1}, - { "show-profile", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED | - M_OPT_NOPROP | M_OPT_OPTIONAL_PARAM, .offset = -1}, - { "list-options", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_FIXED | - M_OPT_NOPROP, .offset = -1}, - OPT_FLAG("list-properties", property_print_help, - CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP), - { "help", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP | - M_OPT_OPTIONAL_PARAM, .offset = -1}, - { "h", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP | - M_OPT_OPTIONAL_PARAM, .offset = -1}, + { "show-profile", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_NOPROP | + M_OPT_OPTIONAL_PARAM, .offset = -1}, + { "list-options", &m_option_type_dummy_flag, CONF_NOCFG | M_OPT_NOPROP, + .offset = -1}, + OPT_FLAG("list-properties", property_print_help, CONF_NOCFG | M_OPT_NOPROP), + { "help", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_NOPROP | M_OPT_OPTIONAL_PARAM, + .offset = -1}, + { "h", CONF_TYPE_STRING, CONF_NOCFG | M_OPT_NOPROP | M_OPT_OPTIONAL_PARAM, + .offset = -1}, OPT_PRINT("list-protocols", stream_print_proto_list), OPT_PRINT("version", print_version), OPT_PRINT("V", print_version), #if HAVE_TESTS - OPT_STRING("unittest", test_mode, CONF_NOCFG | M_OPT_FIXED | M_OPT_NOPROP), + OPT_STRING("unittest", test_mode, CONF_NOCFG | M_OPT_NOPROP), #endif OPT_CHOICE("player-operation-mode", operation_mode, - M_OPT_FIXED | M_OPT_PRE_PARSE | M_OPT_NOPROP, + M_OPT_PRE_PARSE | M_OPT_NOPROP, ({"cplayer", 0}, {"pseudo-gui", 1})), OPT_FLAG("shuffle", shuffle, 0), @@ -378,13 +377,13 @@ const m_option_t mp_opts[] = { {"belownormal", BELOW_NORMAL_PRIORITY_CLASS}, {"idle", IDLE_PRIORITY_CLASS})), #endif - OPT_FLAG("config", load_config, M_OPT_FIXED | CONF_PRE_PARSE), + OPT_FLAG("config", load_config, CONF_PRE_PARSE), OPT_STRING("config-dir", force_configdir, - M_OPT_FIXED | CONF_NOCFG | CONF_PRE_PARSE | M_OPT_FILE), + CONF_NOCFG | CONF_PRE_PARSE | M_OPT_FILE), OPT_STRINGLIST("reset-on-next-file", reset_options, 0), #if HAVE_LUA || HAVE_JAVASCRIPT - OPT_PATHLIST("scripts", script_files, M_OPT_FIXED | M_OPT_FILE), + OPT_PATHLIST("scripts", script_files, M_OPT_FILE), OPT_CLI_ALIAS("script", "scripts-append"), OPT_KEYVALUELIST("script-opts", script_opts, 0), OPT_FLAG("load-scripts", auto_load_scripts, 0), -- cgit v1.2.3