diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-12-20 19:17:43 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-12-20 19:17:43 +0200 |
commit | 0afb326035e66663a90c4609f21560ce772e9718 (patch) | |
tree | 07f443e2bd39745ac7430cff9534529958be9c53 /m_option.c | |
parent | 4a26b4c024498c9b1be4723121d86e0c2b386ed2 (diff) | |
parent | 5bb2f9787f557bd91d5eb9021238ed7b131d5fa9 (diff) | |
download | mpv-0afb326035e66663a90c4609f21560ce772e9718.tar.bz2 mpv-0afb326035e66663a90c4609f21560ce772e9718.tar.xz |
Merge branch 'hr-seek'
* hr-seek:
input: add default keybindings Shift+[arrow] for small exact seeks
input: support bindings with modifier keys for X input
core: audio: make ogg missing audio timing workaround more complex
core: add support for precise non-keyframe-limited seeks
core: add struct for queued seek info
commands: add generic option -> property wrapper
options: add "choice" option type, use for -pts-association-mode
core: remove looping in update_video(), modify command handling a bit
core: seek: use accurate seek mode with audio-only files
core: avoid using sh_video->pts as "current pts"
libvo: register X11 connection fd in input event system
core: timing: add special handling of long frame intervals
core: move central play loop to a separate function
Conflicts:
DOCS/tech/slave.txt
Diffstat (limited to 'm_option.c')
-rw-r--r-- | m_option.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/m_option.c b/m_option.c index 8563d21e9a..a0f01e6344 100644 --- a/m_option.c +++ b/m_option.c @@ -267,6 +267,50 @@ const struct m_option_type m_option_type_intpair = { .set = copy_opt, }; +static int parse_choice(const struct m_option *opt, const char *name, + const char *param, void *dst, int src) +{ + if (param == NULL) + return M_OPT_MISSING_PARAM; + + struct m_opt_choice_alternatives *alt; + for (alt = opt->priv; alt->name; alt++) + if (!strcmp(param, alt->name)) + break; + if (!alt->name) { + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Invalid value for option %s: %s\n", + name, param); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Valid values are:"); + for (alt = opt->priv; alt->name; alt++) + mp_msg(MSGT_CFGPARSER, MSGL_ERR, " %s", alt->name); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "\n"); + return M_OPT_INVALID; + } + if (dst) + *(int *)dst = alt->value; + + return 1; +} + +static char *print_choice(const m_option_t *opt, const void *val) +{ + int v = *(int *)val; + struct m_opt_choice_alternatives *alt; + for (alt = opt->priv; alt->name; alt++) + if (alt->value == v) + return strdup(alt->name); + abort(); +} + +const struct m_option_type m_option_type_choice = { + .name = "String", // same as arbitrary strings in option list for now + .size = sizeof(int), + .parse = parse_choice, + .print = print_choice, + .save = copy_opt, + .set = copy_opt, +}; + // Float #undef VAL |