summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-03-14 21:28:01 +0100
committerwm4 <wm4@nowhere>2020-03-18 19:52:01 +0100
commit26f4f18c0629998a9b91e94722d166866d8b80a3 (patch)
tree16d4891d241d528f63ee99f0017530bba7b3dc8b /audio/out
parentcdd6eb0994bc6aeb8aeb0326e5d8c61c06eb38eb (diff)
downloadmpv-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 'audio/out')
-rw-r--r--audio/out/ao.c11
-rw-r--r--audio/out/ao_alsa.c16
-rw-r--r--audio/out/ao_audiotrack.c4
-rw-r--r--audio/out/ao_coreaudio.c2
-rw-r--r--audio/out/ao_coreaudio_exclusive.c2
-rw-r--r--audio/out/ao_jack.c12
-rw-r--r--audio/out/ao_null.c18
-rw-r--r--audio/out/ao_openal.c6
-rw-r--r--audio/out/ao_opensles.c6
-rw-r--r--audio/out/ao_oss.c4
-rw-r--r--audio/out/ao_pcm.c6
-rw-r--r--audio/out/ao_pulse.c9
-rw-r--r--audio/out/ao_sdl.c2
13 files changed, 51 insertions, 47 deletions
diff --git a/audio/out/ao.c b/audio/out/ao.c
index 0136afca15..42e2cf63d5 100644
--- a/audio/out/ao.c
+++ b/audio/out/ao.c
@@ -136,11 +136,12 @@ static const struct m_obj_list ao_obj_list = {
#define OPT_BASE_STRUCT struct ao_opts
const struct m_sub_options ao_conf = {
.opts = (const struct m_option[]) {
- OPT_SETTINGSLIST("ao", audio_driver_list, UPDATE_AUDIO, &ao_obj_list, ),
- OPT_STRING("audio-device", audio_device, UPDATE_AUDIO),
- OPT_STRING("audio-client-name", audio_client_name, UPDATE_AUDIO),
- OPT_DOUBLE("audio-buffer", audio_buffer,
- UPDATE_AUDIO, .min = 0, .max = 10),
+ {"ao", OPT_SETTINGSLIST(audio_driver_list, &ao_obj_list),
+ .flags = UPDATE_AUDIO},
+ {"audio-device", OPT_STRING(audio_device), .flags = UPDATE_AUDIO},
+ {"audio-client-name", OPT_STRING(audio_client_name), .flags = UPDATE_AUDIO},
+ {"audio-buffer", OPT_DOUBLE(audio_buffer),
+ .flags = UPDATE_AUDIO, M_RANGE(0, 10)},
{0}
},
.size = sizeof(OPT_BASE_STRUCT),
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index bb67fd84a8..b4fa18891b 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -67,14 +67,14 @@ struct ao_alsa_opts {
#define OPT_BASE_STRUCT struct ao_alsa_opts
static const struct m_sub_options ao_alsa_conf = {
.opts = (const struct m_option[]) {
- OPT_FLAG("alsa-resample", resample, 0),
- OPT_STRING("alsa-mixer-device", mixer_device, 0),
- OPT_STRING("alsa-mixer-name", mixer_name, 0),
- OPT_INTRANGE("alsa-mixer-index", mixer_index, 0, 0, 99),
- OPT_FLAG("alsa-non-interleaved", ni, 0),
- OPT_FLAG("alsa-ignore-chmap", ignore_chmap, 0),
- OPT_INTRANGE("alsa-buffer-time", buffer_time, 0, 0, INT_MAX),
- OPT_INTRANGE("alsa-periods", frags, 0, 0, INT_MAX),
+ {"alsa-resample", OPT_FLAG(resample)},
+ {"alsa-mixer-device", OPT_STRING(mixer_device)},
+ {"alsa-mixer-name", OPT_STRING(mixer_name)},
+ {"alsa-mixer-index", OPT_INT(mixer_index), M_RANGE(0, 99)},
+ {"alsa-non-interleaved", OPT_FLAG(ni)},
+ {"alsa-ignore-chmap", OPT_FLAG(ignore_chmap)},
+ {"alsa-buffer-time", OPT_INT(buffer_time), M_RANGE(0, INT_MAX)},
+ {"alsa-periods", OPT_INT(frags), M_RANGE(0, INT_MAX)},
{0}
},
.defaults = &(const struct ao_alsa_opts) {
diff --git a/audio/out/ao_audiotrack.c b/audio/out/ao_audiotrack.c
index f54f2584c0..b3be357c1b 100644
--- a/audio/out/ao_audiotrack.c
+++ b/audio/out/ao_audiotrack.c
@@ -709,8 +709,8 @@ const struct ao_driver audio_out_audiotrack = {
.resume = start,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]) {
- OPT_FLAG("pcm-float", cfg_pcm_float, 0),
- OPT_INT("session-id", cfg_session_id, 0),
+ {"pcm-float", OPT_FLAG(cfg_pcm_float)},
+ {"session-id", OPT_INT(cfg_session_id)},
{0}
},
.options_prefix = "audiotrack",
diff --git a/audio/out/ao_coreaudio.c b/audio/out/ao_coreaudio.c
index 2e02c6842b..533d102d32 100644
--- a/audio/out/ao_coreaudio.c
+++ b/audio/out/ao_coreaudio.c
@@ -423,7 +423,7 @@ const struct ao_driver audio_out_coreaudio = {
.list_devs = ca_get_device_list,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]){
- OPT_FLAG("change-physical-format", change_physical_format, 0),
+ {"change-physical-format", OPT_FLAG(change_physical_format)},
{0}
},
.options_prefix = "coreaudio",
diff --git a/audio/out/ao_coreaudio_exclusive.c b/audio/out/ao_coreaudio_exclusive.c
index a5d4601384..19721e0951 100644
--- a/audio/out/ao_coreaudio_exclusive.c
+++ b/audio/out/ao_coreaudio_exclusive.c
@@ -465,7 +465,7 @@ const struct ao_driver audio_out_coreaudio_exclusive = {
.changed_mixing = false,
},
.options = (const struct m_option[]){
- OPT_FLAG("spdif-hack", spdif_hack, 0),
+ {"spdif-hack", OPT_FLAG(spdif_hack)},
{0}
},
.options_prefix = "coreaudio",
diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c
index 0d5a2da207..249c314f9d 100644
--- a/audio/out/ao_jack.c
+++ b/audio/out/ao_jack.c
@@ -55,12 +55,12 @@ struct jack_opts {
#define OPT_BASE_STRUCT struct jack_opts
static const struct m_sub_options ao_jack_conf = {
.opts = (const struct m_option[]){
- OPT_STRING("jack-port", port, 0),
- OPT_STRING("jack-name", client_name, 0),
- OPT_FLAG("jack-autostart", autostart, 0),
- OPT_FLAG("jack-connect", connect, 0),
- OPT_CHOICE("jack-std-channel-layout", stdlayout, 0,
- ({"waveext", 0}, {"any", 1})),
+ {"jack-port", OPT_STRING(port)},
+ {"jack-name", OPT_STRING(client_name)},
+ {"jack-autostart", OPT_FLAG(autostart)},
+ {"jack-connect", OPT_FLAG(connect)},
+ {"jack-std-channel-layout", OPT_CHOICE(stdlayout,
+ {"waveext", 0}, {"any", 1})},
{0}
},
.defaults = &(const struct jack_opts) {
diff --git a/audio/out/ao_null.c b/audio/out/ao_null.c
index 3880ee8aa4..7e15b58e00 100644
--- a/audio/out/ao_null.c
+++ b/audio/out/ao_null.c
@@ -237,15 +237,15 @@ const struct ao_driver audio_out_null = {
.speed = 1,
},
.options = (const struct m_option[]) {
- OPT_FLAG("untimed", untimed, 0),
- OPT_FLOATRANGE("buffer", bufferlen, 0, 0, 100),
- OPT_INTRANGE("outburst", outburst, 0, 1, 100000),
- OPT_FLOATRANGE("speed", speed, 0, 0, 10000),
- OPT_FLOATRANGE("latency", latency_sec, 0, 0, 100),
- OPT_FLAG("broken-eof", broken_eof, 0),
- OPT_FLAG("broken-delay", broken_delay, 0),
- OPT_CHANNELS("channel-layouts", channel_layouts, 0),
- OPT_AUDIOFORMAT("format", format, 0),
+ {"untimed", OPT_FLAG(untimed)},
+ {"buffer", OPT_FLOAT(bufferlen), M_RANGE(0, 100)},
+ {"outburst", OPT_INT(outburst), M_RANGE(1, 100000)},
+ {"speed", OPT_FLOAT(speed), M_RANGE(0, 10000)},
+ {"latency", OPT_FLOAT(latency_sec), M_RANGE(0, 100)},
+ {"broken-eof", OPT_FLAG(broken_eof)},
+ {"broken-delay", OPT_FLAG(broken_delay)},
+ {"channel-layouts", OPT_CHANNELS(channel_layouts)},
+ {"format", OPT_AUDIOFORMAT(format)},
{0}
},
.options_prefix = "ao-null",
diff --git a/audio/out/ao_openal.c b/audio/out/ao_openal.c
index 2af9fadb4f..53fcaca05e 100644
--- a/audio/out/ao_openal.c
+++ b/audio/out/ao_openal.c
@@ -428,9 +428,9 @@ const struct ao_driver audio_out_openal = {
.direct_channels = 0,
},
.options = (const struct m_option[]) {
- OPT_INTRANGE("num-buffers", num_buffers, 0, 2, MAX_BUF),
- OPT_INTRANGE("num-samples", num_samples, 0, 256, MAX_SAMPLES),
- OPT_FLAG("direct-channels", direct_channels, 0),
+ {"num-buffers", OPT_INT(num_buffers), M_RANGE(2, MAX_BUF)},
+ {"num-samples", OPT_INT(num_samples), M_RANGE(256, MAX_SAMPLES)},
+ {"direct-channels", OPT_FLAG(direct_channels)},
{0}
},
.options_prefix = "openal",
diff --git a/audio/out/ao_opensles.c b/audio/out/ao_opensles.c
index 482a85afea..67ebd46aff 100644
--- a/audio/out/ao_opensles.c
+++ b/audio/out/ao_opensles.c
@@ -254,8 +254,10 @@ const struct ao_driver audio_out_opensles = {
.buffer_size_in_ms = 250,
},
.options = (const struct m_option[]) {
- OPT_INTRANGE("frames-per-enqueue", frames_per_enqueue, 0, 1, 96000),
- OPT_INTRANGE("buffer-size-in-ms", buffer_size_in_ms, 0, 0, 500),
+ {"frames-per-enqueue", OPT_INT(frames_per_enqueue),
+ M_RANGE(1, 96000)},
+ {"buffer-size-in-ms", OPT_INT(buffer_size_in_ms),
+ M_RANGE(0, 500)},
{0}
},
.options_prefix = "opensles",
diff --git a/audio/out/ao_oss.c b/audio/out/ao_oss.c
index fbc535e413..fe87a3db73 100644
--- a/audio/out/ao_oss.c
+++ b/audio/out/ao_oss.c
@@ -649,8 +649,8 @@ const struct ao_driver audio_out_oss = {
.oss_mixer_device = PATH_DEV_MIXER,
},
.options = (const struct m_option[]) {
- OPT_STRING("mixer-device", oss_mixer_device, M_OPT_FILE),
- OPT_STRING("mixer-channel", cfg_oss_mixer_channel, 0),
+ {"mixer-device", OPT_STRING(oss_mixer_device), .flags = M_OPT_FILE},
+ {"mixer-channel", OPT_STRING(cfg_oss_mixer_channel)},
{0}
},
.options_prefix = "oss",
diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c
index 5de213f07d..7d2656be49 100644
--- a/audio/out/ao_pcm.c
+++ b/audio/out/ao_pcm.c
@@ -221,9 +221,9 @@ const struct ao_driver audio_out_pcm = {
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) { .waveheader = 1 },
.options = (const struct m_option[]) {
- OPT_STRING("file", outputfilename, M_OPT_FILE),
- OPT_FLAG("waveheader", waveheader, 0),
- OPT_FLAG("append", append, 0),
+ {"file", OPT_STRING(outputfilename), .flags = M_OPT_FILE},
+ {"waveheader", OPT_FLAG(waveheader)},
+ {"append", OPT_FLAG(append)},
{0}
},
.options_prefix = "ao-pcm",
diff --git a/audio/out/ao_pulse.c b/audio/out/ao_pulse.c
index 5b4ced6f11..fc5fb0caeb 100644
--- a/audio/out/ao_pulse.c
+++ b/audio/out/ao_pulse.c
@@ -837,10 +837,11 @@ const struct ao_driver audio_out_pulse = {
.cfg_buffer = 100,
},
.options = (const struct m_option[]) {
- OPT_STRING("host", cfg_host, 0),
- OPT_CHOICE_OR_INT("buffer", cfg_buffer, 0, 1, 2000, ({"native", 0})),
- OPT_FLAG("latency-hacks", cfg_latency_hacks, 0),
- OPT_FLAG("allow-suspended", cfg_allow_suspended, 0),
+ {"host", OPT_STRING(cfg_host)},
+ {"buffer", OPT_CHOICE(cfg_buffer, {"native", 0}),
+ M_RANGE(1, 2000)},
+ {"latency-hacks", OPT_FLAG(cfg_latency_hacks)},
+ {"allow-suspended", OPT_FLAG(cfg_allow_suspended)},
{0}
},
.options_prefix = "pulse",
diff --git a/audio/out/ao_sdl.c b/audio/out/ao_sdl.c
index 6144918dfe..c1c09b8c92 100644
--- a/audio/out/ao_sdl.c
+++ b/audio/out/ao_sdl.c
@@ -210,7 +210,7 @@ const struct ao_driver audio_out_sdl = {
.buflen = 0, // use SDL default
},
.options = (const struct m_option[]) {
- OPT_FLOAT("buflen", buflen, 0),
+ {"buflen", OPT_FLOAT(buflen)},
{0}
},
.options_prefix = "sdl",