From 049dcf76819ef3239fb90af21df1038235872b9c Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Sun, 8 Dec 2024 13:43:10 +0100 Subject: [PATCH] m_option: don't overlap UPDATE and M_OPT constant values UPDATE_CLIPBOARD currently has the same value as M_OPT_DEFAULT_NAN, so increment all constants after UPDATE_OPT_LAST. But make them start from the end (63) so we can add more UPDATE flags without either forgetting to increase them like in e1d30c4c5a, or having to increase them each time like in a5937ac7e3. --- options/m_option.h | 66 +++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/options/m_option.h b/options/m_option.h index c28b0309934bd..eca38be8d592e 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -215,7 +215,7 @@ struct m_sub_options { 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; + uint64_t change_flags; // Return further sub-options, for example for optional components. If set, // this is called with increasing index (starting from 0), as long as true // is returned. If true is returned and *sub is set in any of these calls, @@ -385,7 +385,7 @@ struct m_option { const m_option_type_t *type; // See \ref OptionFlags. - unsigned int flags; + uint64_t flags; // Always force an option update even if the written value does not change. bool force_update; @@ -424,63 +424,63 @@ struct m_option { char *format_file_size(int64_t size); // The option is forbidden in config files. -#define M_OPT_NOCFG (1 << 2) +#define M_OPT_NOCFG (UINT64_C(1) << 2) // The option should be set during command line pre-parsing -#define M_OPT_PRE_PARSE (1 << 4) +#define M_OPT_PRE_PARSE (UINT64_C(1) << 4) // The option expects a file name (or a list of file names) -#define M_OPT_FILE (1 << 5) +#define M_OPT_FILE (UINT64_C(1) << 5) // Do not add as property. -#define M_OPT_NOPROP (1 << 6) +#define M_OPT_NOPROP (UINT64_C(1) << 6) // Enable special semantics for some options when parsing the string "help". -#define M_OPT_HAVE_HELP (1 << 7) +#define M_OPT_HAVE_HELP (UINT64_C(1) << 7) // The following are also part of the M_OPT_* flags, and are used to update // certain groups of options. -#define UPDATE_OPT_FIRST (1 << 8) -#define UPDATE_TERM (1 << 8) // terminal options -#define UPDATE_SUB_FILT (1 << 9) // subtitle filter options -#define UPDATE_OSD (1 << 10) // related to OSD rendering -#define UPDATE_BUILTIN_SCRIPTS (1 << 11) // osc/ytdl/stats -#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_VOL (1 << 17) // softvol related options -#define UPDATE_LAVFI_COMPLEX (1 << 18) // --lavfi-complex -#define UPDATE_HWDEC (1 << 20) // --hwdec -#define UPDATE_DVB_PROG (1 << 21) // some --dvbin-... -#define UPDATE_SUB_HARD (1 << 22) // subtitle opts. that need full reinit -#define UPDATE_SUB_EXTS (1 << 23) // update internal list of sub exts -#define UPDATE_VIDEO (1 << 24) // force redraw if needed -#define UPDATE_VO (1 << 25) // reinit the VO -#define UPDATE_CLIPBOARD (1 << 26) // reinit the clipboard -#define UPDATE_OPT_LAST (1 << 26) +#define UPDATE_OPT_FIRST (UINT64_C(1) << 8) +#define UPDATE_TERM (UINT64_C(1) << 8) // terminal options +#define UPDATE_SUB_FILT (UINT64_C(1) << 9) // subtitle filter options +#define UPDATE_OSD (UINT64_C(1) << 10) // related to OSD rendering +#define UPDATE_BUILTIN_SCRIPTS (UINT64_C(1) << 11) // osc/ytdl/stats +#define UPDATE_IMGPAR (UINT64_C(1) << 12) // video image params overrides +#define UPDATE_INPUT (UINT64_C(1) << 13) // mostly --input-* options +#define UPDATE_AUDIO (UINT64_C(1) << 14) // --audio-channels etc. +#define UPDATE_PRIORITY (UINT64_C(1) << 15) // --priority (Windows-only) +#define UPDATE_SCREENSAVER (UINT64_C(1) << 16) // --stop-screensaver +#define UPDATE_VOL (UINT64_C(1) << 17) // softvol related options +#define UPDATE_LAVFI_COMPLEX (UINT64_C(1) << 18) // --lavfi-complex +#define UPDATE_HWDEC (UINT64_C(1) << 20) // --hwdec +#define UPDATE_DVB_PROG (UINT64_C(1) << 21) // some --dvbin-... +#define UPDATE_SUB_HARD (UINT64_C(1) << 22) // subtitle opts. that need full reinit +#define UPDATE_SUB_EXTS (UINT64_C(1) << 23) // update internal list of sub exts +#define UPDATE_VIDEO (UINT64_C(1) << 24) // force redraw if needed +#define UPDATE_VO (UINT64_C(1) << 25) // reinit the VO +#define UPDATE_CLIPBOARD (UINT64_C(1) << 26) // reinit the clipboard +#define UPDATE_OPT_LAST (UINT64_C(1) << 26) // All bits between _FIRST and _LAST (inclusive) #define UPDATE_OPTS_MASK \ - (((UPDATE_OPT_LAST << 1) - 1) & ~(unsigned)(UPDATE_OPT_FIRST - 1)) + (((UPDATE_OPT_LAST << 1) - 1) & ~(uint64_t)(UPDATE_OPT_FIRST - 1)) // type_float/type_double: string "default" is parsed as NaN (and reverse) -#define M_OPT_DEFAULT_NAN (1 << 26) +#define M_OPT_DEFAULT_NAN (UINT64_C(1) << 59) // type time: string "no" maps to MP_NOPTS_VALUE (if unset, NOPTS is rejected) // and // parsing: "--no-opt" is parsed as "--opt=no" -#define M_OPT_ALLOW_NO (1 << 27) +#define M_OPT_ALLOW_NO (UINT64_C(1) << 60) // type channels: disallow "auto" (still accept ""), limit list to at most 1 item. -#define M_OPT_CHANNELS_LIMITED (1 << 28) +#define M_OPT_CHANNELS_LIMITED (UINT64_C(1) << 61) // type_float/type_double: controls if pretty print should trim trailing zeros -#define M_OPT_FIXED_LEN_PRINT (1 << 29) +#define M_OPT_FIXED_LEN_PRINT (UINT64_C(1) << 62) // Like M_OPT_TYPE_OPTIONAL_PARAM. -#define M_OPT_OPTIONAL_PARAM (1 << 30) +#define M_OPT_OPTIONAL_PARAM (UINT64_C(1) << 63) // These are kept for compatibility with older code. #define CONF_NOCFG M_OPT_NOCFG