mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 09:32:40 +00:00
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.
This commit is contained in:
parent
20c9538e32
commit
4cae192377
@ -77,25 +77,25 @@ struct mux_stream {
|
||||
#define OPT_BASE_STRUCT struct encode_opts
|
||||
const struct m_sub_options encode_config = {
|
||||
.opts = (const m_option_t[]) {
|
||||
OPT_STRING("o", file, M_OPT_FIXED | CONF_NOCFG | CONF_PRE_PARSE | M_OPT_FILE),
|
||||
OPT_STRING("of", format, M_OPT_FIXED),
|
||||
OPT_KEYVALUELIST("ofopts", fopts, M_OPT_FIXED | M_OPT_HAVE_HELP),
|
||||
OPT_STRING("ovc", vcodec, M_OPT_FIXED),
|
||||
OPT_KEYVALUELIST("ovcopts", vopts, M_OPT_FIXED | M_OPT_HAVE_HELP),
|
||||
OPT_STRING("oac", acodec, M_OPT_FIXED),
|
||||
OPT_KEYVALUELIST("oacopts", aopts, M_OPT_FIXED | M_OPT_HAVE_HELP),
|
||||
OPT_FLOATRANGE("ovoffset", voffset, M_OPT_FIXED, -1000000.0, 1000000.0,
|
||||
OPT_STRING("o", file, CONF_NOCFG | CONF_PRE_PARSE | M_OPT_FILE),
|
||||
OPT_STRING("of", format, 0),
|
||||
OPT_KEYVALUELIST("ofopts", fopts, M_OPT_HAVE_HELP),
|
||||
OPT_STRING("ovc", vcodec, 0),
|
||||
OPT_KEYVALUELIST("ovcopts", vopts, M_OPT_HAVE_HELP),
|
||||
OPT_STRING("oac", acodec, 0),
|
||||
OPT_KEYVALUELIST("oacopts", aopts, M_OPT_HAVE_HELP),
|
||||
OPT_FLOATRANGE("ovoffset", voffset, 0, -1000000.0, 1000000.0,
|
||||
.deprecation_message = "--audio-delay (once unbroken)"),
|
||||
OPT_FLOATRANGE("oaoffset", aoffset, M_OPT_FIXED, -1000000.0, 1000000.0,
|
||||
OPT_FLOATRANGE("oaoffset", aoffset, 0, -1000000.0, 1000000.0,
|
||||
.deprecation_message = "--audio-delay (once unbroken)"),
|
||||
OPT_FLAG("orawts", rawts, M_OPT_FIXED),
|
||||
OPT_FLAG("ovfirst", video_first, M_OPT_FIXED,
|
||||
OPT_FLAG("orawts", rawts, 0),
|
||||
OPT_FLAG("ovfirst", video_first, 0,
|
||||
.deprecation_message = "no replacement"),
|
||||
OPT_FLAG("oafirst", audio_first, M_OPT_FIXED,
|
||||
OPT_FLAG("oafirst", audio_first, 0,
|
||||
.deprecation_message = "no replacement"),
|
||||
OPT_FLAG("ocopy-metadata", copy_metadata, M_OPT_FIXED),
|
||||
OPT_KEYVALUELIST("oset-metadata", set_metadata, M_OPT_FIXED),
|
||||
OPT_STRINGLIST("oremove-metadata", remove_metadata, M_OPT_FIXED),
|
||||
OPT_FLAG("ocopy-metadata", copy_metadata, 0),
|
||||
OPT_KEYVALUELIST("oset-metadata", set_metadata, 0),
|
||||
OPT_STRINGLIST("oremove-metadata", remove_metadata, 0),
|
||||
|
||||
OPT_REMOVED("ocopyts", "ocopyts is now the default"),
|
||||
OPT_REMOVED("oneverdrop", "no replacement"),
|
||||
|
@ -181,7 +181,7 @@ struct input_opts {
|
||||
|
||||
const struct m_sub_options input_config = {
|
||||
.opts = (const m_option_t[]) {
|
||||
OPT_STRING("input-conf", config_file, M_OPT_FIXED | M_OPT_FILE),
|
||||
OPT_STRING("input-conf", config_file, M_OPT_FILE),
|
||||
OPT_INT("input-ar-delay", ar_delay, 0),
|
||||
OPT_INT("input-ar-rate", ar_rate, 0),
|
||||
OPT_PRINT("input-keylist", mp_print_key_list),
|
||||
|
@ -725,9 +725,6 @@ static int handle_set_opt_flags(struct m_config *config,
|
||||
(co->is_set_from_cmdline || co->is_set_from_config))
|
||||
set = false;
|
||||
|
||||
if ((flags & M_SETOPT_NO_FIXED) && (optflags & M_OPT_FIXED))
|
||||
return M_OPT_INVALID;
|
||||
|
||||
if ((flags & M_SETOPT_NO_PRE_PARSE) && (optflags & M_OPT_PRE_PARSE))
|
||||
return M_OPT_INVALID;
|
||||
|
||||
@ -1100,8 +1097,6 @@ void m_config_print_option_list(const struct m_config *config, const char *name)
|
||||
MP_INFO(config, " [not in config files]");
|
||||
if (opt->flags & M_OPT_FILE)
|
||||
MP_INFO(config, " [file]");
|
||||
if (opt->flags & M_OPT_FIXED)
|
||||
MP_INFO(config, " [no runtime changes]");
|
||||
if (opt->type == &m_option_type_alias)
|
||||
MP_INFO(config, " for %s", (char *)opt->priv);
|
||||
if (opt->type == &m_option_type_cli_alias)
|
||||
|
@ -150,13 +150,12 @@ enum {
|
||||
M_SETOPT_FROM_CMDLINE = 8, // Mark as set by command line
|
||||
M_SETOPT_BACKUP = 16, // Call m_config_backup_opt() before
|
||||
M_SETOPT_PRESERVE_CMDLINE = 32, // Don't set if already marked as FROM_CMDLINE
|
||||
M_SETOPT_NO_FIXED = 64, // Reject M_OPT_FIXED options
|
||||
M_SETOPT_NO_PRE_PARSE = 128, // Reject M_OPT_PREPARSE options
|
||||
M_SETOPT_NO_OVERWRITE = 256, // Skip options marked with FROM_*
|
||||
};
|
||||
|
||||
// Flags for safe option setting during runtime.
|
||||
#define M_SETOPT_RUNTIME M_SETOPT_NO_FIXED
|
||||
#define M_SETOPT_RUNTIME 0
|
||||
|
||||
// Set the named option to the given string. This is for command line and config
|
||||
// file use only.
|
||||
|
@ -386,12 +386,6 @@ char *format_file_size(int64_t size);
|
||||
// The option is forbidden in config files.
|
||||
#define M_OPT_NOCFG (1 << 2)
|
||||
|
||||
// Can not be freely changed at runtime (normally, all options can be changed,
|
||||
// even if the settings don't get effective immediately). Note that an option
|
||||
// might still change even if this is set, e.g. via properties or per-file
|
||||
// options.
|
||||
#define M_OPT_FIXED (1 << 3)
|
||||
|
||||
// The option should be set during command line pre-parsing
|
||||
#define M_OPT_PRE_PARSE (1 << 4)
|
||||
|
||||
@ -707,7 +701,7 @@ extern const char m_option_path_separator;
|
||||
|
||||
#define OPT_PRINT(optname, fn) \
|
||||
{.name = optname, \
|
||||
.flags = M_OPT_FIXED | M_OPT_NOCFG | M_OPT_PRE_PARSE | M_OPT_NOPROP, \
|
||||
.flags = M_OPT_NOCFG | M_OPT_PRE_PARSE | M_OPT_NOPROP, \
|
||||
.type = &m_option_type_print_fn, \
|
||||
.priv = MP_EXPECT_TYPE(m_opt_print_fn, fn), \
|
||||
.offset = -1}
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user