diff options
author | Max Kellermann <max@duempel.org> | 2013-08-04 12:25:08 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-08-04 14:07:49 +0200 |
commit | 81c3224076da6ad727debc6bab8a5422f7322451 (patch) | |
tree | 1da1912caa6c7ff863f7affeafae22e9e6004e8f /src/output | |
parent | 7a1d466fb279659048e80e2853a7906c90d73235 (diff) | |
download | mpd-81c3224076da6ad727debc6bab8a5422f7322451.tar.gz mpd-81c3224076da6ad727debc6bab8a5422f7322451.tar.xz mpd-81c3224076da6ad727debc6bab8a5422f7322451.zip |
OutputPlugin: pass config_param reference
Diffstat (limited to '')
-rw-r--r-- | src/output/AlsaOutputPlugin.cxx | 28 | ||||
-rw-r--r-- | src/output/AoOutputPlugin.cxx | 16 | ||||
-rw-r--r-- | src/output/FifoOutputPlugin.cxx | 6 | ||||
-rw-r--r-- | src/output/HttpdInternal.hxx | 2 | ||||
-rw-r--r-- | src/output/HttpdOutputPlugin.cxx | 22 | ||||
-rw-r--r-- | src/output/JackOutputPlugin.cxx | 27 | ||||
-rw-r--r-- | src/output/NullOutputPlugin.cxx | 6 | ||||
-rw-r--r-- | src/output/OSXOutputPlugin.cxx | 6 | ||||
-rw-r--r-- | src/output/OpenALOutputPlugin.cxx | 7 | ||||
-rw-r--r-- | src/output/OssOutputPlugin.cxx | 9 | ||||
-rw-r--r-- | src/output/PipeOutputPlugin.cxx | 10 | ||||
-rw-r--r-- | src/output/PulseOutputPlugin.cxx | 12 | ||||
-rw-r--r-- | src/output/RecorderOutputPlugin.cxx | 14 | ||||
-rw-r--r-- | src/output/RoarOutputPlugin.cxx | 10 | ||||
-rw-r--r-- | src/output/ShoutOutputPlugin.cxx | 47 | ||||
-rw-r--r-- | src/output/SolarisOutputPlugin.cxx | 6 | ||||
-rw-r--r-- | src/output/WinmmOutputPlugin.cxx | 4 |
17 files changed, 112 insertions, 120 deletions
diff --git a/src/output/AlsaOutputPlugin.cxx b/src/output/AlsaOutputPlugin.cxx index 0e70babb6..b26a3e1df 100644 --- a/src/output/AlsaOutputPlugin.cxx +++ b/src/output/AlsaOutputPlugin.cxx @@ -37,9 +37,7 @@ static const char default_device[] = "default"; -enum { - MPD_ALSA_BUFFER_TIME_US = 500000, -}; +static constexpr unsigned MPD_ALSA_BUFFER_TIME_US = 500000; #define MPD_ALSA_RETRY_NR 5 @@ -117,7 +115,7 @@ struct AlsaOutput { AlsaOutput():mode(0), writei(snd_pcm_writei) { } - bool Init(const config_param *param, GError **error_r) { + bool Init(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &alsa_output_plugin, param, error_r); } @@ -143,36 +141,36 @@ alsa_device(const AlsaOutput *ad) } static void -alsa_configure(AlsaOutput *ad, const struct config_param *param) +alsa_configure(AlsaOutput *ad, const config_param ¶m) { - ad->device = config_get_block_string(param, "device", ""); + ad->device = param.GetBlockValue("device", ""); - ad->use_mmap = config_get_block_bool(param, "use_mmap", false); + ad->use_mmap = param.GetBlockValue("use_mmap", false); - ad->dsd_usb = config_get_block_bool(param, "dsd_usb", false); + ad->dsd_usb = param.GetBlockValue("dsd_usb", false); - ad->buffer_time = config_get_block_unsigned(param, "buffer_time", - MPD_ALSA_BUFFER_TIME_US); - ad->period_time = config_get_block_unsigned(param, "period_time", 0); + ad->buffer_time = param.GetBlockValue("buffer_time", + MPD_ALSA_BUFFER_TIME_US); + ad->period_time = param.GetBlockValue("period_time", 0u); #ifdef SND_PCM_NO_AUTO_RESAMPLE - if (!config_get_block_bool(param, "auto_resample", true)) + if (!param.GetBlockValue("auto_resample", true)) ad->mode |= SND_PCM_NO_AUTO_RESAMPLE; #endif #ifdef SND_PCM_NO_AUTO_CHANNELS - if (!config_get_block_bool(param, "auto_channels", true)) + if (!param.GetBlockValue("auto_channels", true)) ad->mode |= SND_PCM_NO_AUTO_CHANNELS; #endif #ifdef SND_PCM_NO_AUTO_FORMAT - if (!config_get_block_bool(param, "auto_format", true)) + if (!param.GetBlockValue("auto_format", true)) ad->mode |= SND_PCM_NO_AUTO_FORMAT; #endif } static struct audio_output * -alsa_init(const struct config_param *param, GError **error_r) +alsa_init(const config_param ¶m, GError **error_r) { AlsaOutput *ad = new AlsaOutput(); diff --git a/src/output/AoOutputPlugin.cxx b/src/output/AoOutputPlugin.cxx index d25a30973..db7b9a360 100644 --- a/src/output/AoOutputPlugin.cxx +++ b/src/output/AoOutputPlugin.cxx @@ -42,7 +42,7 @@ struct AoOutput { ao_option *options; ao_device *device; - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &ao_output_plugin, param, error_r); } @@ -51,7 +51,7 @@ struct AoOutput { ao_base_finish(&base); } - bool Configure(const config_param *param, GError **error_r); + bool Configure(const config_param ¶m, GError **error_r); }; static inline GQuark @@ -95,20 +95,20 @@ ao_output_error(GError **error_r) } inline bool -AoOutput::Configure(const config_param *param, GError **error_r) +AoOutput::Configure(const config_param ¶m, GError **error_r) { const char *value; options = nullptr; - write_size = config_get_block_unsigned(param, "write_size", 1024); + write_size = param.GetBlockValue("write_size", 1024u); if (ao_output_ref == 0) { ao_initialize(); } ao_output_ref++; - value = config_get_block_string(param, "driver", "default"); + value = param.GetBlockValue("driver", "default"); if (0 == strcmp(value, "default")) driver = ao_default_driver_id(); else @@ -129,9 +129,9 @@ AoOutput::Configure(const config_param *param, GError **error_r) } g_debug("using ao driver \"%s\" for \"%s\"\n", ai->short_name, - config_get_block_string(param, "name", nullptr)); + param.GetBlockValue("name", nullptr)); - value = config_get_block_string(param, "options", nullptr); + value = param.GetBlockValue("options", nullptr); if (value != nullptr) { gchar **_options = g_strsplit(value, ";", 0); @@ -158,7 +158,7 @@ AoOutput::Configure(const config_param *param, GError **error_r) } static struct audio_output * -ao_output_init(const config_param *param, GError **error_r) +ao_output_init(const config_param ¶m, GError **error_r) { AoOutput *ad = new AoOutput(); diff --git a/src/output/FifoOutputPlugin.cxx b/src/output/FifoOutputPlugin.cxx index a0d07c702..50062988c 100644 --- a/src/output/FifoOutputPlugin.cxx +++ b/src/output/FifoOutputPlugin.cxx @@ -53,7 +53,7 @@ struct FifoOutput { g_free(path); } - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &fifo_output_plugin, param, error_r); } @@ -186,10 +186,10 @@ fifo_open(FifoOutput *fd, GError **error_r) } static struct audio_output * -fifo_output_init(const config_param *param, GError **error_r) +fifo_output_init(const config_param ¶m, GError **error_r) { GError *error = nullptr; - char *path = config_dup_block_path(param, "path", &error); + char *path = param.DupBlockPath("path", &error); if (!path) { if (error != nullptr) g_propagate_error(error_r, error); diff --git a/src/output/HttpdInternal.hxx b/src/output/HttpdInternal.hxx index 8bc0c130e..e8a37e033 100644 --- a/src/output/HttpdInternal.hxx +++ b/src/output/HttpdInternal.hxx @@ -123,7 +123,7 @@ struct HttpdOutput final : private ServerSocket { HttpdOutput(EventLoop &_loop); ~HttpdOutput(); - bool Configure(const config_param *param, GError **error_r); + bool Configure(const config_param ¶m, GError **error_r); bool Bind(GError **error_r); void Unbind(); diff --git a/src/output/HttpdOutputPlugin.cxx b/src/output/HttpdOutputPlugin.cxx index 462dd3429..21774bac9 100644 --- a/src/output/HttpdOutputPlugin.cxx +++ b/src/output/HttpdOutputPlugin.cxx @@ -91,18 +91,17 @@ HttpdOutput::Unbind() } inline bool -HttpdOutput::Configure(const config_param *param, GError **error_r) +HttpdOutput::Configure(const config_param ¶m, GError **error_r) { /* read configuration */ - name = config_get_block_string(param, "name", "Set name in config"); - genre = config_get_block_string(param, "genre", "Set genre in config"); - website = config_get_block_string(param, "website", - "Set website in config"); + name = param.GetBlockValue("name", "Set name in config"); + genre = param.GetBlockValue("genre", "Set genre in config"); + website = param.GetBlockValue("website", "Set website in config"); - guint port = config_get_block_unsigned(param, "port", 8000); + guint port = param.GetBlockValue("port", 8000u); const char *encoder_name = - config_get_block_string(param, "encoder", "vorbis"); + param.GetBlockValue("encoder", "vorbis"); const auto encoder_plugin = encoder_plugin_get(encoder_name); if (encoder_plugin == NULL) { g_set_error(error_r, httpd_output_quark(), 0, @@ -110,12 +109,11 @@ HttpdOutput::Configure(const config_param *param, GError **error_r) return false; } - clients_max = config_get_block_unsigned(param,"max_clients", 0); + clients_max = param.GetBlockValue("max_clients", 0u); /* set up bind_to_address */ - const char *bind_to_address = - config_get_block_string(param, "bind_to_address", NULL); + const char *bind_to_address = param.GetBlockValue("bind_to_address"); bool success = bind_to_address != NULL && strcmp(bind_to_address, "any") != 0 ? AddHost(bind_to_address, port, error_r) @@ -125,7 +123,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r) /* initialize encoder */ - encoder = encoder_init(*encoder_plugin, param, error_r); + encoder = encoder_init(*encoder_plugin, ¶m, error_r); if (encoder == nullptr) return false; @@ -138,7 +136,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r) } static struct audio_output * -httpd_output_init(const struct config_param *param, +httpd_output_init(const struct config_param ¶m, GError **error_r) { HttpdOutput *httpd = new HttpdOutput(*main_loop); diff --git a/src/output/JackOutputPlugin.cxx b/src/output/JackOutputPlugin.cxx index 6c9ee9335..241857d82 100644 --- a/src/output/JackOutputPlugin.cxx +++ b/src/output/JackOutputPlugin.cxx @@ -82,7 +82,7 @@ struct JackOutput { */ bool pause; - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &jack_output_plugin, param, error_r); } @@ -323,7 +323,7 @@ parse_port_list(int line, const char *source, char **dest, GError **error_r) } static struct audio_output * -mpd_jack_init(const config_param *param, GError **error_r) +mpd_jack_init(const config_param ¶m, GError **error_r) { JackOutput *jd = new JackOutput(); @@ -336,7 +336,7 @@ mpd_jack_init(const config_param *param, GError **error_r) jd->options = JackNullOption; - jd->name = config_get_block_string(param, "client_name", nullptr); + jd->name = param.GetBlockValue("client_name", nullptr); if (jd->name != nullptr) jd->options = jack_options_t(jd->options | JackUseExactName); else @@ -344,35 +344,35 @@ mpd_jack_init(const config_param *param, GError **error_r) care about the JackUseExactName option */ jd->name = "Music Player Daemon"; - jd->server_name = config_get_block_string(param, "server_name", nullptr); + jd->server_name = param.GetBlockValue("server_name", nullptr); if (jd->server_name != nullptr) jd->options = jack_options_t(jd->options | JackServerName); - if (!config_get_block_bool(param, "autostart", false)) + if (!param.GetBlockValue("autostart", false)) jd->options = jack_options_t(jd->options | JackNoStartServer); /* configure the source ports */ - value = config_get_block_string(param, "source_ports", "left,right"); - jd->num_source_ports = parse_port_list(param->line, value, + value = param.GetBlockValue("source_ports", "left,right"); + jd->num_source_ports = parse_port_list(param.line, value, jd->source_ports, error_r); if (jd->num_source_ports == 0) return nullptr; /* configure the destination ports */ - value = config_get_block_string(param, "destination_ports", nullptr); + value = param.GetBlockValue("destination_ports", nullptr); if (value == nullptr) { /* compatibility with MPD < 0.16 */ - value = config_get_block_string(param, "ports", nullptr); + value = param.GetBlockValue("ports", nullptr); if (value != nullptr) g_warning("deprecated option 'ports' in line %d", - param->line); + param.line); } if (value != nullptr) { jd->num_destination_ports = - parse_port_list(param->line, value, + parse_port_list(param.line, value, jd->destination_ports, error_r); if (jd->num_destination_ports == 0) return nullptr; @@ -385,10 +385,9 @@ mpd_jack_init(const config_param *param, GError **error_r) g_warning("number of source ports (%u) mismatches the " "number of destination ports (%u) in line %d", jd->num_source_ports, jd->num_destination_ports, - param->line); + param.line); - jd->ringbuffer_size = - config_get_block_unsigned(param, "ringbuffer_size", 32768); + jd->ringbuffer_size = param.GetBlockValue("ringbuffer_size", 32768u); jack_set_error_function(mpd_jack_error); diff --git a/src/output/NullOutputPlugin.cxx b/src/output/NullOutputPlugin.cxx index 814a9d2e2..0ce32fbda 100644 --- a/src/output/NullOutputPlugin.cxx +++ b/src/output/NullOutputPlugin.cxx @@ -31,7 +31,7 @@ struct NullOutput { Timer *timer; - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &null_output_plugin, param, error_r); } @@ -42,7 +42,7 @@ struct NullOutput { }; static struct audio_output * -null_init(const config_param *param, GError **error_r) +null_init(const config_param ¶m, GError **error_r) { NullOutput *nd = new NullOutput(); @@ -51,7 +51,7 @@ null_init(const config_param *param, GError **error_r) return nullptr; } - nd->sync = config_get_block_bool(param, "sync", true); + nd->sync = param.GetBlockValue("sync", true); return &nd->base; } diff --git a/src/output/OSXOutputPlugin.cxx b/src/output/OSXOutputPlugin.cxx index afe8e064d..6e42b2518 100644 --- a/src/output/OSXOutputPlugin.cxx +++ b/src/output/OSXOutputPlugin.cxx @@ -65,9 +65,9 @@ osx_output_test_default_device(void) } static void -osx_output_configure(OSXOutput *oo, const struct config_param *param) +osx_output_configure(OSXOutput *oo, const config_param ¶m) { - const char *device = config_get_block_string(param, "device", NULL); + const char *device = param.GetBlockValue("device"); if (device == NULL || 0 == strcmp(device, "default")) { oo->component_subtype = kAudioUnitSubType_DefaultOutput; @@ -85,7 +85,7 @@ osx_output_configure(OSXOutput *oo, const struct config_param *param) } static struct audio_output * -osx_output_init(const struct config_param *param, GError **error_r) +osx_output_init(const config_param ¶m, GError **error_r) { OSXOutput *oo = new OSXOutput(); if (!ao_base_init(&oo->base, &osx_output_plugin, param, error_r)) { diff --git a/src/output/OpenALOutputPlugin.cxx b/src/output/OpenALOutputPlugin.cxx index 81c75f6c4..1864052fa 100644 --- a/src/output/OpenALOutputPlugin.cxx +++ b/src/output/OpenALOutputPlugin.cxx @@ -49,7 +49,7 @@ struct OpenALOutput { ALenum format; ALuint frequency; - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &openal_output_plugin, param, error_r); } @@ -140,10 +140,9 @@ openal_setup_context(OpenALOutput *od, } static struct audio_output * -openal_init(const config_param *param, GError **error_r) +openal_init(const config_param ¶m, GError **error_r) { - const char *device_name = config_get_block_string(param, "device", nullptr); - + const char *device_name = param.GetBlockValue("device"); if (device_name == nullptr) { device_name = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER); } diff --git a/src/output/OssOutputPlugin.cxx b/src/output/OssOutputPlugin.cxx index 49b02386b..2ef0edd67 100644 --- a/src/output/OssOutputPlugin.cxx +++ b/src/output/OssOutputPlugin.cxx @@ -80,7 +80,7 @@ struct OssOutput { OssOutput():fd(-1), device(nullptr) {} - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &oss_output_plugin, param, error_r); } @@ -160,11 +160,12 @@ oss_open_default(GError **error) int err[G_N_ELEMENTS(default_devices)]; enum oss_stat ret[G_N_ELEMENTS(default_devices)]; + const config_param empty; for (int i = G_N_ELEMENTS(default_devices); --i >= 0; ) { ret[i] = oss_stat_device(default_devices[i], &err[i]); if (ret[i] == OSS_STAT_NO_ERROR) { OssOutput *od = new OssOutput(); - if (!od->Initialize(nullptr, error)) { + if (!od->Initialize(empty, error)) { delete od; return NULL; } @@ -201,9 +202,9 @@ oss_open_default(GError **error) } static struct audio_output * -oss_output_init(const config_param *param, GError **error_r) +oss_output_init(const config_param ¶m, GError **error_r) { - const char *device = config_get_block_string(param, "device", NULL); + const char *device = param.GetBlockValue("device"); if (device != NULL) { OssOutput *od = new OssOutput(); if (!od->Initialize(param, error_r)) { diff --git a/src/output/PipeOutputPlugin.cxx b/src/output/PipeOutputPlugin.cxx index f76dd04c1..f485f1554 100644 --- a/src/output/PipeOutputPlugin.cxx +++ b/src/output/PipeOutputPlugin.cxx @@ -30,7 +30,7 @@ struct PipeOutput { char *cmd; FILE *fh; - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &pipe_output_plugin, param, error_r); } @@ -39,7 +39,7 @@ struct PipeOutput { ao_base_finish(&base); } - bool Configure(const config_param *param, GError **error_r); + bool Configure(const config_param ¶m, GError **error_r); }; /** @@ -52,9 +52,9 @@ pipe_output_quark(void) } inline bool -PipeOutput::Configure(const config_param *param, GError **error_r) +PipeOutput::Configure(const config_param ¶m, GError **error_r) { - cmd = config_dup_block_string(param, "command", nullptr); + cmd = param.DupBlockString("command"); if (cmd == nullptr) { g_set_error(error_r, pipe_output_quark(), 0, "No \"command\" parameter specified"); @@ -65,7 +65,7 @@ PipeOutput::Configure(const config_param *param, GError **error_r) } static struct audio_output * -pipe_output_init(const config_param *param, GError **error_r) +pipe_output_init(const config_param ¶m, GError **error_r) { PipeOutput *pd = new PipeOutput(); diff --git a/src/output/PulseOutputPlugin.cxx b/src/output/PulseOutputPlugin.cxx index 65526c8fb..f59c8d76e 100644 --- a/src/output/PulseOutputPlugin.cxx +++ b/src/output/PulseOutputPlugin.cxx @@ -344,7 +344,7 @@ pulse_output_setup_context(PulseOutput *po, GError **error_r) } static struct audio_output * -pulse_output_init(const struct config_param *param, GError **error_r) +pulse_output_init(const config_param ¶m, GError **error_r) { PulseOutput *po; @@ -356,9 +356,9 @@ pulse_output_init(const struct config_param *param, GError **error_r) return nullptr; } - po->name = config_get_block_string(param, "name", "mpd_pulse"); - po->server = config_get_block_string(param, "server", nullptr); - po->sink = config_get_block_string(param, "sink", nullptr); + po->name = param.GetBlockValue("name", "mpd_pulse"); + po->server = param.GetBlockValue("server"); + po->sink = param.GetBlockValue("sink"); po->mixer = nullptr; po->mainloop = nullptr; @@ -923,10 +923,10 @@ pulse_output_pause(struct audio_output *ao) static bool pulse_output_test_default_device(void) { - PulseOutput *po; bool success; - po = (PulseOutput *)pulse_output_init(nullptr, nullptr); + const config_param empty; + PulseOutput *po = (PulseOutput *)pulse_output_init(empty, nullptr); if (po == nullptr) return false; diff --git a/src/output/RecorderOutputPlugin.cxx b/src/output/RecorderOutputPlugin.cxx index 2e77463f0..8da6d88f2 100644 --- a/src/output/RecorderOutputPlugin.cxx +++ b/src/output/RecorderOutputPlugin.cxx @@ -57,7 +57,7 @@ struct RecorderOutput { */ char buffer[32768]; - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &recorder_output_plugin, param, error_r); } @@ -66,7 +66,7 @@ struct RecorderOutput { ao_base_finish(&base); } - bool Configure(const config_param *param, GError **error_r); + bool Configure(const config_param ¶m, GError **error_r); bool WriteToFile(const void *data, size_t length, GError **error_r); @@ -86,12 +86,12 @@ recorder_output_quark(void) } inline bool -RecorderOutput::Configure(const config_param *param, GError **error_r) +RecorderOutput::Configure(const config_param ¶m, GError **error_r) { /* read configuration */ const char *encoder_name = - config_get_block_string(param, "encoder", "vorbis"); + param.GetBlockValue("encoder", "vorbis"); const auto encoder_plugin = encoder_plugin_get(encoder_name); if (encoder_plugin == nullptr) { g_set_error(error_r, recorder_output_quark(), 0, @@ -99,7 +99,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r) return false; } - path = config_get_block_string(param, "path", nullptr); + path = param.GetBlockValue("path"); if (path == nullptr) { g_set_error(error_r, recorder_output_quark(), 0, "'path' not configured"); @@ -108,7 +108,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r) /* initialize encoder */ - encoder = encoder_init(*encoder_plugin, param, error_r); + encoder = encoder_init(*encoder_plugin, ¶m, error_r); if (encoder == nullptr) return false; @@ -116,7 +116,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r) } static audio_output * -recorder_output_init(const config_param *param, GError **error_r) +recorder_output_init(const config_param ¶m, GError **error_r) { RecorderOutput *recorder = new RecorderOutput(); diff --git a/src/output/RoarOutputPlugin.cxx b/src/output/RoarOutputPlugin.cxx index bf2bf1789..36f7c395b 100644 --- a/src/output/RoarOutputPlugin.cxx +++ b/src/output/RoarOutputPlugin.cxx @@ -108,19 +108,19 @@ roar_output_set_volume(RoarOutput *roar, unsigned volume) } static void -roar_configure(RoarOutput *self, const struct config_param *param) +roar_configure(RoarOutput *self, const config_param ¶m) { - self->host = config_dup_block_string(param, "server", nullptr); - self->name = config_dup_block_string(param, "name", "MPD"); + self->host = param.DupBlockString("server", nullptr); + self->name = param.DupBlockString("name", "MPD"); - const char *role = config_get_block_string(param, "role", "music"); + const char *role = param.GetBlockValue("role", "music"); self->role = role != nullptr ? roar_str2role(role) : ROAR_ROLE_MUSIC; } static struct audio_output * -roar_init(const struct config_param *param, GError **error_r) +roar_init(const config_param ¶m, GError **error_r) { RoarOutput *self = new RoarOutput(); diff --git a/src/output/ShoutOutputPlugin.cxx b/src/output/ShoutOutputPlugin.cxx index fbad24ec8..1f307eafc 100644 --- a/src/output/ShoutOutputPlugin.cxx +++ b/src/output/ShoutOutputPlugin.cxx @@ -35,7 +35,7 @@ #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "shout" -#define DEFAULT_CONN_TIMEOUT 2 +static constexpr unsigned DEFAULT_CONN_TIMEOUT = 2; struct ShoutOutput final { struct audio_output base; @@ -66,7 +66,7 @@ struct ShoutOutput final { shout_free(shout_conn); } - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &shout_output_plugin, param, error_r); } @@ -75,7 +75,7 @@ struct ShoutOutput final { ao_base_finish(&base); } - bool Configure(const config_param *param, GError **error_r); + bool Configure(const config_param ¶m, GError **error_r); }; static int shout_init_count; @@ -102,18 +102,18 @@ shout_encoder_plugin_get(const char *name) gcc_pure static const char * -require_block_string(const struct config_param *param, const char *name) +require_block_string(const config_param ¶m, const char *name) { - const char *value = config_get_block_string(param, name, nullptr); + const char *value = param.GetBlockValue(name); if (value == nullptr) MPD_ERROR("no \"%s\" defined for shout device defined at line " \ - "%i\n", name, param->line); \ + "%i\n", name, param.line); return value; } inline bool -ShoutOutput::Configure(const config_param *param, GError **error_r) +ShoutOutput::Configure(const config_param ¶m, GError **error_r) { const AudioFormat audio_format = base.config_audio_format; @@ -125,8 +125,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) const char *host = require_block_string(param, "host"); const char *mount = require_block_string(param, "mount"); - - unsigned port = config_get_block_unsigned(param, "port", 0); + unsigned port = param.GetBlockValue("port", 0u); if (port == 0) { g_set_error(error_r, shout_output_quark(), 0, "shout port must be configured"); @@ -136,11 +135,11 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) const char *passwd = require_block_string(param, "password"); const char *name = require_block_string(param, "name"); - bool is_public = config_get_block_bool(param, "public", false); + bool is_public = param.GetBlockValue("public", false); - const char *user = config_get_block_string(param, "user", "source"); + const char *user = param.GetBlockValue("user", "source"); - const char *value = config_get_block_string(param, "quality", nullptr); + const char *value = param.GetBlockValue("quality"); if (value != nullptr) { char *test; quality = strtod(value, &test); @@ -149,18 +148,18 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) g_set_error(error_r, shout_output_quark(), 0, "shout quality \"%s\" is not a number in the " "range -1 to 10, line %i", - value, param->line); + value, param.line); return false; } - if (config_get_block_string(param, "bitrate", nullptr) != nullptr) { + if (param.GetBlockValue("bitrate") != nullptr) { g_set_error(error_r, shout_output_quark(), 0, "quality and bitrate are " "both defined"); return false; } } else { - value = config_get_block_string(param, "bitrate", nullptr); + value = param.GetBlockValue("bitrate"); if (value == nullptr) { g_set_error(error_r, shout_output_quark(), 0, "neither bitrate nor quality defined"); @@ -177,8 +176,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) } } - const char *encoding = config_get_block_string(param, "encoding", - "ogg"); + const char *encoding = param.GetBlockValue("encoding", "ogg"); const auto encoder_plugin = shout_encoder_plugin_get(encoding); if (encoder_plugin == nullptr) { g_set_error(error_r, shout_output_quark(), 0, @@ -187,7 +185,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) return false; } - encoder = encoder_init(*encoder_plugin, param, error_r); + encoder = encoder_init(*encoder_plugin, ¶m, error_r); if (encoder == nullptr) return false; @@ -198,7 +196,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) shout_format = SHOUT_FORMAT_OGG; unsigned protocol; - value = config_get_block_string(param, "protocol", nullptr); + value = param.GetBlockValue("protocol"); if (value != nullptr) { if (0 == strcmp(value, "shoutcast") && 0 != strcmp(encoding, "mp3")) { @@ -240,24 +238,23 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) } /* optional paramters */ - timeout = config_get_block_unsigned(param, "timeout", - DEFAULT_CONN_TIMEOUT); + timeout = param.GetBlockValue("timeout", DEFAULT_CONN_TIMEOUT); - value = config_get_block_string(param, "genre", nullptr); + value = param.GetBlockValue("genre"); if (value != nullptr && shout_set_genre(shout_conn, value)) { g_set_error(error_r, shout_output_quark(), 0, "%s", shout_get_error(shout_conn)); return false; } - value = config_get_block_string(param, "description", nullptr); + value = param.GetBlockValue("description"); if (value != nullptr && shout_set_description(shout_conn, value)) { g_set_error(error_r, shout_output_quark(), 0, "%s", shout_get_error(shout_conn)); return false; } - value = config_get_block_string(param, "url", nullptr); + value = param.GetBlockValue("url"); if (value != nullptr && shout_set_url(shout_conn, value)) { g_set_error(error_r, shout_output_quark(), 0, "%s", shout_get_error(shout_conn)); @@ -290,7 +287,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r) } static struct audio_output * -my_shout_init_driver(const config_param *param, GError **error_r) +my_shout_init_driver(const config_param ¶m, GError **error_r) { ShoutOutput *sd = new ShoutOutput(); if (!sd->Initialize(param, error_r)) { diff --git a/src/output/SolarisOutputPlugin.cxx b/src/output/SolarisOutputPlugin.cxx index 81c793e21..074eae728 100644 --- a/src/output/SolarisOutputPlugin.cxx +++ b/src/output/SolarisOutputPlugin.cxx @@ -61,7 +61,7 @@ struct SolarisOutput { int fd; - bool Initialize(const config_param *param, GError **error_r) { + bool Initialize(const config_param ¶m, GError **error_r) { return ao_base_init(&base, &solaris_output_plugin, param, error_r); } @@ -90,7 +90,7 @@ solaris_output_test_default_device(void) } static struct audio_output * -solaris_output_init(const config_param *param, GError **error_r) +solaris_output_init(const config_param ¶m, GError **error_r) { SolarisOutput *so = new SolarisOutput(); if (!so->Initialize(param, error_r)) { @@ -98,7 +98,7 @@ solaris_output_init(const config_param *param, GError **error_r) return nullptr; } - so->device = config_get_block_string(param, "device", "/dev/audio"); + so->device = param.GetBlockValue("device", "/dev/audio"); return &so->base; } diff --git a/src/output/WinmmOutputPlugin.cxx b/src/output/WinmmOutputPlugin.cxx index de6927bd2..d02b52c58 100644 --- a/src/output/WinmmOutputPlugin.cxx +++ b/src/output/WinmmOutputPlugin.cxx @@ -114,7 +114,7 @@ fail: } static struct audio_output * -winmm_output_init(const struct config_param *param, GError **error_r) +winmm_output_init(const config_param ¶m, GError **error_r) { WinmmOutput *wo = new WinmmOutput(); if (!ao_base_init(&wo->base, &winmm_output_plugin, param, error_r)) { @@ -122,7 +122,7 @@ winmm_output_init(const struct config_param *param, GError **error_r) return nullptr; } - const char *device = config_get_block_string(param, "device", nullptr); + const char *device = param.GetBlockValue("device"); if (!get_device_id(device, &wo->device_id, error_r)) { ao_base_finish(&wo->base); g_free(wo); |