Skip to content

Commit

Permalink
options: transition options from OPT_FLAG to OPT_BOOL
Browse files Browse the repository at this point in the history
c784820 introduced a bool option type
as a replacement for the flag type, but didn't actually transition and
remove the flag type because it would have been too much mundane work.
  • Loading branch information
christoph-heinrich authored and Dudemanguy committed Feb 21, 2023
1 parent b9850a6 commit 91cc0d8
Show file tree
Hide file tree
Showing 80 changed files with 550 additions and 576 deletions.
5 changes: 2 additions & 3 deletions audio/decode/ad_lavc.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,22 @@ struct priv {
#define OPT_BASE_STRUCT struct ad_lavc_params
struct ad_lavc_params {
float ac3drc;
int downmix;
bool downmix;
int threads;
char **avopts;
};

const struct m_sub_options ad_lavc_conf = {
.opts = (const m_option_t[]) {
{"ac3drc", OPT_FLOAT(ac3drc), M_RANGE(0, 6)},
{"downmix", OPT_FLAG(downmix)},
{"downmix", OPT_BOOL(downmix)},
{"threads", OPT_INT(threads), M_RANGE(0, 16)},
{"o", OPT_KEYVALUELIST(avopts)},
{0}
},
.size = sizeof(struct ad_lavc_params),
.defaults = &(const struct ad_lavc_params){
.ac3drc = 0,
.downmix = 0,
.threads = 1,
},
};
Expand Down
4 changes: 2 additions & 2 deletions audio/filter/af_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct f_opts {
int out_srate;
struct m_channels out_channels;

int fail;
bool fail;
};

struct priv {
Expand Down Expand Up @@ -135,7 +135,7 @@ const struct mp_user_filter_entry af_format = {
{"out-srate", OPT_INT(out_srate), M_RANGE(1000, 8*48000)},
{"out-channels", OPT_CHANNELS(out_channels),
.flags = M_OPT_CHANNELS_LIMITED},
{"fail", OPT_FLAG(fail)},
{"fail", OPT_BOOL(fail)},
{0}
},
},
Expand Down
6 changes: 3 additions & 3 deletions audio/filter/af_lavcac3enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const static uint16_t ac3_bitrate_tab[19] = {
};

struct f_opts {
int add_iec61937_header;
bool add_iec61937_header;
int bit_rate;
int min_channel_num;
char *encoder;
Expand Down Expand Up @@ -418,13 +418,13 @@ const struct mp_user_filter_entry af_lavcac3enc = {
.name = "lavcac3enc",
.priv_size = sizeof(OPT_BASE_STRUCT),
.priv_defaults = &(const OPT_BASE_STRUCT) {
.add_iec61937_header = 1,
.add_iec61937_header = true,
.bit_rate = 640,
.min_channel_num = 3,
.encoder = "ac3",
},
.options = (const struct m_option[]) {
{"tospdif", OPT_FLAG(add_iec61937_header)},
{"tospdif", OPT_BOOL(add_iec61937_header)},
{"bitrate", OPT_CHOICE(bit_rate,
{"auto", 0}, {"default", 0}), M_RANGE(32, 640)},
{"minch", OPT_INT(min_channel_num), M_RANGE(2, 6)},
Expand Down
13 changes: 6 additions & 7 deletions audio/out/ao_alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ struct ao_alsa_opts {
char *mixer_device;
char *mixer_name;
int mixer_index;
int resample;
int ni;
int ignore_chmap;
bool resample;
bool ni;
bool ignore_chmap;
int buffer_time;
int frags;
};

#define OPT_BASE_STRUCT struct ao_alsa_opts
static const struct m_sub_options ao_alsa_conf = {
.opts = (const struct m_option[]) {
{"alsa-resample", OPT_FLAG(resample)},
{"alsa-resample", OPT_BOOL(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-non-interleaved", OPT_BOOL(ni)},
{"alsa-ignore-chmap", OPT_BOOL(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}
Expand All @@ -80,7 +80,6 @@ static const struct m_sub_options ao_alsa_conf = {
.mixer_device = "default",
.mixer_name = "Master",
.mixer_index = 0,
.ni = 0,
.buffer_time = 100000,
.frags = 4,
},
Expand Down
4 changes: 2 additions & 2 deletions audio/out/ao_audiotrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct priv {
jfloatArray floatarray;
jobject bbuf;

int cfg_pcm_float;
bool cfg_pcm_float;
int cfg_session_id;

bool needs_timestamp_offset;
Expand Down Expand Up @@ -818,7 +818,7 @@ const struct ao_driver audio_out_audiotrack = {
.start = start,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]) {
{"pcm-float", OPT_FLAG(cfg_pcm_float)},
{"pcm-float", OPT_BOOL(cfg_pcm_float)},
{"session-id", OPT_INT(cfg_session_id)},
{0}
},
Expand Down
4 changes: 2 additions & 2 deletions audio/out/ao_coreaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct priv {
AudioStreamBasicDescription original_asbd;
AudioStreamID original_asbd_stream;

int change_physical_format;
bool change_physical_format;
};

static int64_t ca_get_hardware_latency(struct ao *ao) {
Expand Down Expand Up @@ -421,7 +421,7 @@ const struct ao_driver audio_out_coreaudio = {
.list_devs = ca_get_device_list,
.priv_size = sizeof(struct priv),
.options = (const struct m_option[]){
{"change-physical-format", OPT_FLAG(change_physical_format)},
{"change-physical-format", OPT_BOOL(change_physical_format)},
{0}
},
.options_prefix = "coreaudio",
Expand Down
5 changes: 2 additions & 3 deletions audio/out/ao_coreaudio_exclusive.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct priv {
AudioStreamBasicDescription original_asbd;

// Output s16 physical format, float32 virtual format, ac3/dts mpv format
int spdif_hack;
bool spdif_hack;

bool changed_mixing;

Expand Down Expand Up @@ -461,10 +461,9 @@ const struct ao_driver audio_out_coreaudio_exclusive = {
.hog_pid = -1,
.stream = 0,
.stream_idx = -1,
.changed_mixing = false,
},
.options = (const struct m_option[]){
{"spdif-hack", OPT_FLAG(spdif_hack)},
{"spdif-hack", OPT_BOOL(spdif_hack)},
{0}
},
.options_prefix = "coreaudio",
Expand Down
10 changes: 5 additions & 5 deletions audio/out/ao_jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
struct jack_opts {
char *port;
char *client_name;
int connect;
int autostart;
bool connect;
bool autostart;
int stdlayout;
};

Expand All @@ -57,15 +57,15 @@ static const struct m_sub_options ao_jack_conf = {
.opts = (const struct m_option[]){
{"jack-port", OPT_STRING(port)},
{"jack-name", OPT_STRING(client_name)},
{"jack-autostart", OPT_FLAG(autostart)},
{"jack-connect", OPT_FLAG(connect)},
{"jack-autostart", OPT_BOOL(autostart)},
{"jack-connect", OPT_BOOL(connect)},
{"jack-std-channel-layout", OPT_CHOICE(stdlayout,
{"waveext", 0}, {"any", 1})},
{0}
},
.defaults = &(const struct jack_opts) {
.client_name = "mpv",
.connect = 1,
.connect = true,
},
.size = sizeof(struct jack_opts),
};
Expand Down
12 changes: 6 additions & 6 deletions audio/out/ao_null.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ struct priv {
int buffersize; // samples
bool playing;

int untimed;
bool untimed;
float bufferlen; // seconds
float speed; // multiplier
float latency_sec; // seconds
float latency; // samples
int broken_eof;
int broken_delay;
bool broken_eof;
bool broken_delay;

// Minimal unit of audio samples that can be written at once. If play() is
// called with sizes not aligned to this, a rounded size will be returned.
Expand Down Expand Up @@ -215,13 +215,13 @@ const struct ao_driver audio_out_null = {
.speed = 1,
},
.options = (const struct m_option[]) {
{"untimed", OPT_FLAG(untimed)},
{"untimed", OPT_BOOL(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)},
{"broken-eof", OPT_BOOL(broken_eof)},
{"broken-delay", OPT_BOOL(broken_delay)},
{"channel-layouts", OPT_CHANNELS(channel_layouts)},
{"format", OPT_AUDIOFORMAT(format)},
{0}
Expand Down
6 changes: 3 additions & 3 deletions audio/out/ao_openal.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct priv {
ALenum al_format;
int num_buffers;
int num_samples;
int direct_channels;
bool direct_channels;
};

static int control(struct ao *ao, enum aocontrol cmd, void *arg)
Expand Down Expand Up @@ -389,12 +389,12 @@ const struct ao_driver audio_out_openal = {
.priv_defaults = &(const struct priv) {
.num_buffers = 4,
.num_samples = 8192,
.direct_channels = 1,
.direct_channels = true,
},
.options = (const struct m_option[]) {
{"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)},
{"direct-channels", OPT_BOOL(direct_channels)},
{0}
},
.options_prefix = "openal",
Expand Down
1 change: 0 additions & 1 deletion audio/out/ao_oss.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,5 @@ const struct ao_driver audio_out_oss = {
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) {
.dsp_fd = -1,
.playing = false,
},
};
10 changes: 5 additions & 5 deletions audio/out/ao_pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

struct priv {
char *outputfilename;
int waveheader;
int append;
bool waveheader;
bool append;
uint64_t data_length;
FILE *fp;
};
Expand Down Expand Up @@ -237,11 +237,11 @@ const struct ao_driver audio_out_pcm = {
.start = start,
.reset = reset,
.priv_size = sizeof(struct priv),
.priv_defaults = &(const struct priv) { .waveheader = 1 },
.priv_defaults = &(const struct priv) { .waveheader = true },
.options = (const struct m_option[]) {
{"file", OPT_STRING(outputfilename), .flags = M_OPT_FILE},
{"waveheader", OPT_FLAG(waveheader)},
{"append", OPT_FLAG(append)},
{"waveheader", OPT_BOOL(waveheader)},
{"append", OPT_BOOL(append)},
{0}
},
.options_prefix = "ao-pcm",
Expand Down
8 changes: 4 additions & 4 deletions audio/out/ao_pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ struct priv {

char *cfg_host;
int cfg_buffer;
int cfg_latency_hacks;
int cfg_allow_suspended;
bool cfg_latency_hacks;
bool cfg_allow_suspended;
};

#define GENERIC_ERR_MSG(str) \
Expand Down Expand Up @@ -810,8 +810,8 @@ const struct ao_driver audio_out_pulse = {
{"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)},
{"latency-hacks", OPT_BOOL(cfg_latency_hacks)},
{"allow-suspended", OPT_BOOL(cfg_allow_suspended)},
{0}
},
.options_prefix = "pulse",
Expand Down
8 changes: 4 additions & 4 deletions common/encode.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ struct encode_opts {
char **aopts;
float voffset;
float aoffset;
int rawts;
int video_first;
int audio_first;
int copy_metadata;
bool rawts;
bool video_first;
bool audio_first;
bool copy_metadata;
char **set_metadata;
char **remove_metadata;
};
Expand Down
10 changes: 5 additions & 5 deletions common/encode_lavc.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ const struct m_sub_options encode_config = {
.deprecation_message = "--audio-delay (once unbroken)"},
{"oaoffset", OPT_FLOAT(aoffset), M_RANGE(-1000000.0, 1000000.0),
.deprecation_message = "--audio-delay (once unbroken)"},
{"orawts", OPT_FLAG(rawts)},
{"ovfirst", OPT_FLAG(video_first),
{"orawts", OPT_BOOL(rawts)},
{"ovfirst", OPT_BOOL(video_first),
.deprecation_message = "no replacement"},
{"oafirst", OPT_FLAG(audio_first),
{"oafirst", OPT_BOOL(audio_first),
.deprecation_message = "no replacement"},
{"ocopy-metadata", OPT_FLAG(copy_metadata)},
{"ocopy-metadata", OPT_BOOL(copy_metadata)},
{"oset-metadata", OPT_KEYVALUELIST(set_metadata)},
{"oremove-metadata", OPT_STRINGLIST(remove_metadata)},

Expand All @@ -106,7 +106,7 @@ const struct m_sub_options encode_config = {
},
.size = sizeof(struct encode_opts),
.defaults = &(const struct encode_opts){
.copy_metadata = 1,
.copy_metadata = true,
},
};

Expand Down
Loading

0 comments on commit 91cc0d8

Please sign in to comment.