diff options
Diffstat (limited to 'options/m_option.h')
-rw-r--r-- | options/m_option.h | 113 |
1 files changed, 70 insertions, 43 deletions
diff --git a/options/m_option.h b/options/m_option.h index 80be447c42..d784d8f54d 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -38,7 +38,6 @@ struct mpv_node; // Simple types extern const m_option_type_t m_option_type_flag; extern const m_option_type_t m_option_type_store; -extern const m_option_type_t m_option_type_float_store; extern const m_option_type_t m_option_type_int; extern const m_option_type_t m_option_type_int64; extern const m_option_type_t m_option_type_intpair; @@ -62,7 +61,9 @@ extern const m_option_type_t m_option_type_color; extern const m_option_type_t m_option_type_geometry; extern const m_option_type_t m_option_type_size_box; extern const m_option_type_t m_option_type_channels; +extern const m_option_type_t m_option_type_aspect; extern const m_option_type_t m_option_type_node; +extern const m_option_type_t m_option_type_subopt_legacy; // Used internally by m_config.c extern const m_option_type_t m_option_type_alias; @@ -129,6 +130,12 @@ struct m_obj_desc { // Set by m_obj_list_find(). If the requested name is an old alias, this // is set to the old name (while the name field uses the new name). const char *replaced_name; + // For convenience: these are added as global command-line options. + const struct m_sub_options *global_opts; + // Evil hack to essentially force-move .options to global_opts. All options + // will be added as global options with the given prefix, and using + // sub-options will be treated as deprecated and redirected. + const char *legacy_prefix; }; // Extra definition needed for \ref m_option_type_obj_settings_list options. @@ -142,6 +149,8 @@ struct m_obj_list { // Allow unknown entries, for which a dummy entry is inserted, and whose // options are skipped and ignored. bool allow_unknown_entries; + // This helps with confusing error messages if unknown flag options are used. + bool disallow_positional_parameters; }; // Find entry by name @@ -182,6 +191,9 @@ struct m_sub_options { const struct m_option *opts; size_t size; const void *defaults; + // Change flags passed to mp_option_change_callback() if any option that is + // directly or indirectly part of this group is changed. + int change_flags; }; #define CONF_TYPE_FLAG (&m_option_type_flag) @@ -207,7 +219,6 @@ struct m_sub_options { union m_option_value { int flag; // not the C type "bool"! int store; - float float_store; int int_; int64_t int64; int intpair[2]; @@ -291,13 +302,6 @@ struct m_option_type { // to the valid value range of the option. void (*multiply)(const m_option_t *opt, void *val, double f); - // Clamp the value in val to the option's valid value range. - // Return values: - // M_OPT_OUT_OF_RANGE: val was invalid, and modified (clamped) to be valid - // M_OPT_INVALID: val was invalid, and can't be made valid - // 0: val was already valid and is unchanged - int (*clamp)(const m_option_t *opt, void *val); - // Set the option value in dst to the contents of src. // (If the option is dynamic, the old value in *dst has to be freed.) // Return values: @@ -359,30 +363,45 @@ struct m_option { // The option is forbidden in config files. #define M_OPT_NOCFG (1 << 2) -// This option can't be set per-file when used with struct m_config. -#define M_OPT_GLOBAL (1 << 4) - // 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 << 5) +#define M_OPT_FIXED (1 << 3) // The option should be set during command line pre-parsing -#define M_OPT_PRE_PARSE (1 << 6) +#define M_OPT_PRE_PARSE (1 << 4) // The option expects a file name (or a list of file names) -#define M_OPT_FILE (1 << 11) - -// Logging-related option - used to update log/terminal settings eagerly -#define M_OPT_TERM (1 << 12) +#define M_OPT_FILE (1 << 5) + +// Do not add as property. +#define M_OPT_NOPROP (1 << 6) + +// The following are also part of the M_OPT_* flags, and are used to update +// certain groups of options. +#define UPDATE_OPT_FIRST (1 << 7) +#define UPDATE_TERM (1 << 7) // terminal options +#define UPDATE_RENDERER (1 << 8) // mainly vo_opengl options +#define UPDATE_VIDEOPOS (1 << 9) // video position (panscan etc.) +#define UPDATE_OSD (1 << 10) // related to OSD rendering +#define UPDATE_BUILTIN_SCRIPTS (1 << 11) // osc/ytdl +#define UPDATE_IMGPAR (1 << 12) // video image params overrides +#define UPDATE_INPUT (1 << 13) // mostly --input-* options +#define UPDATE_AUDIO (1 << 14) // --audio-channels etc. +#define UPDATE_PRIORITY (1 << 15) // --priority (Windows-only) +#define UPDATE_SCREENSAVER (1 << 16) // --stop-screensaver +#define UPDATE_OPT_LAST (1 << 16) + +// All bits between _FIRST and _LAST (inclusive) +#define UPDATE_OPTS_MASK \ + (((UPDATE_OPT_LAST << 1) - 1) & ~(unsigned)(UPDATE_OPT_FIRST - 1)) // These are kept for compatibility with older code. #define CONF_MIN M_OPT_MIN #define CONF_MAX M_OPT_MAX #define CONF_RANGE M_OPT_RANGE #define CONF_NOCFG M_OPT_NOCFG -#define CONF_GLOBAL (M_OPT_GLOBAL | M_OPT_FIXED) #define CONF_PRE_PARSE M_OPT_PRE_PARSE // These flags are used to describe special parser capabilities or behavior. @@ -403,19 +422,11 @@ struct m_option { */ #define M_OPT_TYPE_ALLOW_WILDCARD (1 << 1) -// Dynamic data type. -/** This flag indicates that the data is dynamically allocated (m_option::p - * points to a pointer). It enables a little hack in the \ref Config which - * replaces the initial value of such variables with a dynamic copy in case - * the initial value is statically allocated (pretty common with strings). - */ -#define M_OPT_TYPE_DYNAMIC (1 << 2) - // The parameter is optional and by default no parameter is preferred. If // ambiguous syntax is used ("--opt value"), the command line parser will // assume that the argument takes no parameter. In config files, these // options can be used without "=" and value. -#define M_OPT_TYPE_OPTIONAL_PARAM (1 << 3) +#define M_OPT_TYPE_OPTIONAL_PARAM (1 << 2) ///////////////////////////// Parser flags ///////////////////////////////// @@ -424,8 +435,7 @@ struct m_option { // On success parsers return a number >= 0. // // To indicate that MPlayer should exit without playing anything, -// parsers return M_OPT_EXIT minus the number of parameters they -// consumed: \ref M_OPT_EXIT or \ref M_OPT_EXIT-1. +// parsers return M_OPT_EXIT. // // On error one of the following (negative) error codes is returned: @@ -449,8 +459,6 @@ struct m_option { #define M_OPT_PARSER_ERR -6 // Returned when MPlayer should exit. Used by various help stuff. -/** M_OPT_EXIT must be the lowest number on this list. - */ #define M_OPT_EXIT -7 char *m_option_strerror(int code); @@ -577,10 +585,6 @@ extern const char m_option_path_separator; OPT_GENERAL(int, optname, varname, flags, .max = value, \ .type = &m_option_type_store) -#define OPT_FLOAT_STORE(optname, varname, flags, value) \ - OPT_GENERAL(float, optname, varname, flags, .max = value, \ - .type = &m_option_type_float_store) - #define OPT_STRINGLIST(...) \ OPT_GENERAL(char**, __VA_ARGS__, .type = &m_option_type_string_list) @@ -622,10 +626,11 @@ extern const char m_option_path_separator; #define OPT_STRING(...) \ OPT_GENERAL(char*, __VA_ARGS__, .type = &m_option_type_string) -#define OPT_SETTINGSLIST(optname, varname, flags, objlist) \ +#define OPT_SETTINGSLIST(optname, varname, flags, objlist, ...) \ OPT_GENERAL(m_obj_settings_t*, optname, varname, flags, \ .type = &m_option_type_obj_settings_list, \ - .priv = (void*)MP_EXPECT_TYPE(const struct m_obj_list*, objlist)) + .priv = (void*)MP_EXPECT_TYPE(const struct m_obj_list*, objlist), \ + __VA_ARGS__) #define OPT_IMAGEFORMAT(...) \ OPT_GENERAL(int, __VA_ARGS__, .type = &m_option_type_imgfmt) @@ -682,6 +687,9 @@ extern const char m_option_path_separator; #define OPT_TRACKCHOICE(name, var) \ OPT_CHOICE_OR_INT(name, var, 0, 0, 8190, ({"no", -2}, {"auto", -1})) +#define OPT_ASPECT(...) \ + OPT_GENERAL(float, __VA_ARGS__, .type = &m_option_type_aspect) + #define OPT_STRING_VALIDATE_(optname, varname, flags, validate_fn, ...) \ OPT_GENERAL(char*, optname, varname, flags, __VA_ARGS__, \ .priv = MP_EXPECT_TYPE(m_opt_string_validate_fn, validate_fn)) @@ -690,7 +698,7 @@ extern const char m_option_path_separator; #define OPT_PRINT(optname, fn) \ {.name = optname, \ - .flags = M_OPT_FIXED | M_OPT_GLOBAL | M_OPT_NOCFG | M_OPT_PRE_PARSE, \ + .flags = M_OPT_FIXED | M_OPT_NOCFG | M_OPT_PRE_PARSE, \ .type = &m_option_type_print_fn, \ .priv = MP_EXPECT_TYPE(m_opt_print_fn, fn), \ .offset = -1} @@ -706,13 +714,32 @@ extern const char m_option_path_separator; .type = &m_option_type_subconfig, \ .priv = (void*)&subconf) -// If "--name" was removed, but "--newname" has the same semantics. +// Same as above, but for legacy suboption usage, which have no associated +// field (no actual data anywhere). +#define OPT_SUBSTRUCT_LEGACY(optname, subconf) \ + {.name = optname, .offset = -1, .type = &m_option_type_subconfig, \ + .priv = (void*)&subconf} + +// Provide a another name for the option. +#define OPT_ALIAS(optname, newname) \ + {.name = optname, .type = &m_option_type_alias, .priv = newname, \ + .offset = -1} + +// If "--optname" was removed, but "--newname" has the same semantics. // It will be redirected, and a warning will be printed on first use. #define OPT_REPLACED(optname, newname) \ - {.name = optname, .type = &m_option_type_alias, .priv = newname, .offset = -1} + {.name = optname, .type = &m_option_type_alias, .priv = newname, \ + .deprecation_message = "", .offset = -1} -// "--name" doesn't exist, but inform the user about a replacement with msg. +// "--optname" doesn't exist, but inform the user about a replacement with msg. #define OPT_REMOVED(optname, msg) \ - {.name = optname, .type = &m_option_type_removed, .priv = msg, .offset = -1} + {.name = optname, .type = &m_option_type_removed, .priv = msg, \ + .deprecation_message = "", .offset = -1} + +// Redirect a suboption (e.g. from --vo) to a global option. The redirection +// is handled as a special case instead of being applied automatically. +#define OPT_SUBOPT_LEGACY(optname, globalname) \ + {.name = optname, .type = &m_option_type_subopt_legacy, .priv = globalname, \ + .offset = -1} #endif /* MPLAYER_M_OPTION_H */ |