From 9d32d62b6154784a4e38dcb0ff50b8331e9169bf Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 9 Apr 2020 11:08:03 +0200 Subject: options: fix ab-loop-* properties These used ".min = MP_NOPTS_VALUE" to indicate certain exceptions. This broke with the recent change to how min/max are handled, which made setting min or max mean that a value range is used, thus setting max=0. Fix this by not using magic a value in .min; replace it with a proper flag. Fixes: #7596 --- options/m_option.c | 2 +- options/m_option.h | 5 ++++- options/options.c | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/options/m_option.c b/options/m_option.c index a7b02b8819..fcc52406ff 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -2639,7 +2639,7 @@ static int parse_timestring(struct bstr str, double *time, char endchar) return len; } -#define HAS_NOPTS(opt) ((opt)->min == MP_NOPTS_VALUE) +#define HAS_NOPTS(opt) ((opt)->flags & M_OPT_ALLOW_NO) static int parse_time(struct mp_log *log, const m_option_t *opt, struct bstr name, struct bstr param, void *dst) diff --git a/options/m_option.h b/options/m_option.h index 84336ae3ce..8a8b54b510 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -427,7 +427,10 @@ char *format_file_size(int64_t size); (((UPDATE_OPT_LAST << 1) - 1) & ~(unsigned)(UPDATE_OPT_FIRST - 1)) // type_float/type_double: string "default" is parsed as NaN (and reverse) -#define M_OPT_DEFAULT_NAN (1 << 29) +#define M_OPT_DEFAULT_NAN (1 << 25) + +// type time: string "no" maps to MP_NOPTS_VALUE (if unset, NOPTS is rejected) +#define M_OPT_ALLOW_NO (1 << 26) // Like M_OPT_TYPE_OPTIONAL_PARAM. #define M_OPT_OPTIONAL_PARAM (1 << 30) diff --git a/options/options.c b/options/options.c index c7d75b0648..3536e439a0 100644 --- a/options/options.c +++ b/options/options.c @@ -447,8 +447,8 @@ static const m_option_t mp_opts[] = { {"rebase-start-time", OPT_FLAG(rebase_start_time)}, - {"ab-loop-a", OPT_TIME(ab_loop[0]), .min = MP_NOPTS_VALUE}, - {"ab-loop-b", OPT_TIME(ab_loop[1]), .min = MP_NOPTS_VALUE}, + {"ab-loop-a", OPT_TIME(ab_loop[0]), .flags = M_OPT_ALLOW_NO}, + {"ab-loop-b", OPT_TIME(ab_loop[1]), .flags = M_OPT_ALLOW_NO}, {"ab-loop-count", OPT_CHOICE(ab_loop_count, {"inf", -1}), M_RANGE(0, INT_MAX)}, -- cgit v1.2.3