summaryrefslogtreecommitdiffstats
path: root/m_option.h
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-18 01:00:28 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-12-18 10:14:25 +0200
commit7e366113f75c696ae2b32f5faa5f80ec3fca96b8 (patch)
treea205a59524df6a617c8a33afb17cce983a6a2901 /m_option.h
parent00c2bafb0ac25a9c5ce845f49f6718b06ff03bbe (diff)
downloadmpv-7e366113f75c696ae2b32f5faa5f80ec3fca96b8.tar.bz2
mpv-7e366113f75c696ae2b32f5faa5f80ec3fca96b8.tar.xz
options: add "choice" option type, use for -pts-association-mode
Add a "choice" option type. Options of this type take a string as input and set an int option variable to the value corresponding to the string. The string->int mapping is option-specific and is given in the option definition. Strings not found in the mapping are rejected as invalid option values. Change the option -pts-association-mode to use this new option type and accept values "auto, decoder, sort" instead of "0, 1, 2". The change in accepted values shouldn't cause problems as this option is not appropriate to use in normal user config files.
Diffstat (limited to 'm_option.h')
-rw-r--r--m_option.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/m_option.h b/m_option.h
index 26c457e24d..ed2b30de75 100644
--- a/m_option.h
+++ b/m_option.h
@@ -53,6 +53,7 @@ extern const m_option_type_t m_option_type_string_list;
extern const m_option_type_t m_option_type_position;
extern const m_option_type_t m_option_type_time;
extern const m_option_type_t m_option_type_time_size;
+extern const m_option_type_t m_option_type_choice;
extern const m_option_type_t m_option_type_print;
extern const m_option_type_t m_option_type_print_indirect;
@@ -169,6 +170,11 @@ typedef struct {
/// Ready made settings to parse a \ref m_span_t with a start-end syntax.
extern const m_obj_params_t m_span_params_def;
+struct m_opt_choice_alternatives {
+ char *name;
+ int value;
+};
+
// FIXME: backward compatibility
#define CONF_TYPE_FLAG (&m_option_type_flag)
@@ -543,5 +549,7 @@ int parse_timestring(const char *str, double *time, char endchar);
#define OPT_STRING(optname, varname, flags) {optname, NULL, &m_option_type_string, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)}
#define OPT_SETTINGSLIST(optname, varname, flags, objlist) {optname, NULL, &m_option_type_obj_settings_list, flags, 0, 0, objlist, 1, offsetof(struct MPOpts, varname)}
#define OPT_AUDIOFORMAT(optname, varname, flags) {optname, NULL, &m_option_type_afmt, flags, 0, 0, NULL, 1, offsetof(struct MPOpts, varname)}
+#define OPT_HELPER_REMOVEPAREN(...) __VA_ARGS__
+#define OPT_CHOICE(optname, varname, flags, choices) {optname, NULL, &m_option_type_choice, flags, 0, 0, &(const struct m_opt_choice_alternatives[]){OPT_HELPER_REMOVEPAREN choices, {NULL}}, 1, offsetof(struct MPOpts, varname)}
#endif /* MPLAYER_M_OPTION_H */