diff options
author | wm4 <wm4@nowhere> | 2020-03-14 21:28:01 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-03-18 19:52:01 +0100 |
commit | 26f4f18c0629998a9b91e94722d166866d8b80a3 (patch) | |
tree | 16d4891d241d528f63ee99f0017530bba7b3dc8b /stream | |
parent | cdd6eb0994bc6aeb8aeb0326e5d8c61c06eb38eb (diff) | |
download | mpv-26f4f18c0629998a9b91e94722d166866d8b80a3.tar.bz2 mpv-26f4f18c0629998a9b91e94722d166866d8b80a3.tar.xz |
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
Diffstat (limited to 'stream')
-rw-r--r-- | stream/stream.c | 6 | ||||
-rw-r--r-- | stream/stream_cdda.c | 22 | ||||
-rw-r--r-- | stream/stream_dvb.c | 14 | ||||
-rw-r--r-- | stream/stream_lavf.c | 24 |
4 files changed, 33 insertions, 33 deletions
diff --git a/stream/stream.c b/stream/stream.c index f5f61e93c9..c7339b4c66 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -106,9 +106,9 @@ struct stream_opts { const struct m_sub_options stream_conf = { .opts = (const struct m_option[]){ - OPT_BYTE_SIZE("stream-buffer-size", buffer_size, 0, - STREAM_MIN_BUFFER_SIZE, 512 * 1024 * 1024), - OPT_FLAG("load-unsafe-playlists", load_unsafe_playlists, 0), + {"stream-buffer-size", OPT_BYTE_SIZE(buffer_size), + M_RANGE(STREAM_MIN_BUFFER_SIZE, 512 * 1024 * 1024)}, + {"load-unsafe-playlists", OPT_FLAG(load_unsafe_playlists)}, {0} }, .size = sizeof(struct stream_opts), diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index 375f1ebba3..b00bb22539 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -76,17 +76,17 @@ typedef struct cdda_params { #define OPT_BASE_STRUCT struct cdda_params const struct m_sub_options stream_cdda_conf = { .opts = (const m_option_t[]) { - OPT_INTRANGE("speed", speed, 0, 1, 100), - OPT_INTRANGE("paranoia", paranoia_mode, 0, 0, 2), - OPT_INTRANGE("sector-size", sector_size, 0, 1, 100), - OPT_INTRANGE("overlap", search_overlap, 0, 0, 75), - OPT_INT("toc-bias", toc_bias, 0), - OPT_INT("toc-offset", toc_offset, 0), - OPT_FLAG("skip", skip, 0), - OPT_INT("span-a", span[0], 0), - OPT_INT("span-b", span[1], 0), - OPT_FLAG("cdtext", cdtext, 0), - OPT_REMOVED("span", "use span-a/span-b"), + {"speed", OPT_INT(speed), M_RANGE(1, 100)}, + {"paranoia", OPT_INT(paranoia_mode), M_RANGE(0, 2)}, + {"sector-size", OPT_INT(sector_size), M_RANGE(1, 100)}, + {"overlap", OPT_INT(search_overlap), M_RANGE(0, 75)}, + {"toc-bias", OPT_INT(toc_bias)}, + {"toc-offset", OPT_INT(toc_offset)}, + {"skip", OPT_FLAG(skip)}, + {"span-a", OPT_INT(span[0])}, + {"span-b", OPT_INT(span[1])}, + {"cdtext", OPT_FLAG(cdtext)}, + {"span", OPT_REMOVED("use span-a/span-b")}, {0} }, .size = sizeof(struct cdda_params), diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index c6edaa03e9..1111d3d7a5 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -73,13 +73,13 @@ static pthread_mutex_t global_dvb_state_lock = PTHREAD_MUTEX_INITIALIZER; const struct m_sub_options stream_dvb_conf = { .opts = (const m_option_t[]) { - OPT_STRING("prog", cfg_prog, UPDATE_DVB_PROG), - OPT_INTRANGE("card", cfg_devno, 0, 0, MAX_ADAPTERS-1), - OPT_INTRANGE("timeout", cfg_timeout, 0, 1, 30), - OPT_STRING("file", cfg_file, M_OPT_FILE), - OPT_FLAG("full-transponder", cfg_full_transponder, 0), - OPT_INT("channel-switch-offset", cfg_channel_switch_offset, - UPDATE_DVB_PROG), + {"prog", OPT_STRING(cfg_prog), .flags = UPDATE_DVB_PROG}, + {"card", OPT_INT(cfg_devno), M_RANGE(0, MAX_ADAPTERS-1)}, + {"timeout", OPT_INT(cfg_timeout), M_RANGE(1, 30)}, + {"file", OPT_STRING(cfg_file), .flags = M_OPT_FILE}, + {"full-transponder", OPT_FLAG(cfg_full_transponder)}, + {"channel-switch-offset", OPT_INT(cfg_channel_switch_offset), + .flags = UPDATE_DVB_PROG}, {0} }, .size = sizeof(dvb_opts_t), diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index 65c6b82a64..8bbfab8af8 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -52,18 +52,18 @@ struct stream_lavf_params { const struct m_sub_options stream_lavf_conf = { .opts = (const m_option_t[]) { - OPT_KEYVALUELIST("stream-lavf-o", avopts, 0), - OPT_STRINGLIST("http-header-fields", http_header_fields, 0), - OPT_STRING("user-agent", useragent, 0), - OPT_STRING("referrer", referrer, 0), - OPT_FLAG("cookies", cookies_enabled, 0), - OPT_STRING("cookies-file", cookies_file, M_OPT_FILE), - OPT_FLAG("tls-verify", tls_verify, 0), - OPT_STRING("tls-ca-file", tls_ca_file, M_OPT_FILE), - OPT_STRING("tls-cert-file", tls_cert_file, M_OPT_FILE), - OPT_STRING("tls-key-file", tls_key_file, M_OPT_FILE), - OPT_DOUBLE("network-timeout", timeout, 0, .min = 0, .max = DBL_MAX), - OPT_STRING("http-proxy", http_proxy, 0), + {"stream-lavf-o", OPT_KEYVALUELIST(avopts)}, + {"http-header-fields", OPT_STRINGLIST(http_header_fields)}, + {"user-agent", OPT_STRING(useragent)}, + {"referrer", OPT_STRING(referrer)}, + {"cookies", OPT_FLAG(cookies_enabled)}, + {"cookies-file", OPT_STRING(cookies_file), .flags = M_OPT_FILE}, + {"tls-verify", OPT_FLAG(tls_verify)}, + {"tls-ca-file", OPT_STRING(tls_ca_file), .flags = M_OPT_FILE}, + {"tls-cert-file", OPT_STRING(tls_cert_file), .flags = M_OPT_FILE}, + {"tls-key-file", OPT_STRING(tls_key_file), .flags = M_OPT_FILE}, + {"network-timeout", OPT_DOUBLE(timeout), M_RANGE(0, DBL_MAX)}, + {"http-proxy", OPT_STRING(http_proxy)}, {0} }, .size = sizeof(struct stream_lavf_params), |