From 4fa5538e2bed36903b403e1aaee2462d22b456dc Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 21 Jan 2015 22:13:44 +0100 Subject: config/Param: split block-specific attributes to new struct ConfigBlock The old struct config_param remains only for top-level string options. --- src/output/plugins/ShoutOutputPlugin.cxx | 54 ++++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/output/plugins/ShoutOutputPlugin.cxx') diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index 9157afd37..339c4e491 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -68,11 +68,11 @@ struct ShoutOutput final { shout_free(shout_conn); } - bool Initialize(const config_param ¶m, Error &error) { - return base.Configure(param, error); + bool Initialize(const ConfigBlock &block, Error &error) { + return base.Configure(block, error); } - bool Configure(const config_param ¶m, Error &error); + bool Configure(const ConfigBlock &block, Error &error); }; static int shout_init_count; @@ -92,18 +92,18 @@ shout_encoder_plugin_get(const char *name) gcc_pure static const char * -require_block_string(const config_param ¶m, const char *name) +require_block_string(const ConfigBlock &block, const char *name) { - const char *value = param.GetBlockValue(name); + const char *value = block.GetBlockValue(name); if (value == nullptr) FormatFatalError("no \"%s\" defined for shout device defined " - "at line %d\n", name, param.line); + "at line %d\n", name, block.line); return value; } inline bool -ShoutOutput::Configure(const config_param ¶m, Error &error) +ShoutOutput::Configure(const ConfigBlock &block, Error &error) { const AudioFormat audio_format = base.config_audio_format; @@ -113,22 +113,22 @@ ShoutOutput::Configure(const config_param ¶m, Error &error) return false; } - const char *host = require_block_string(param, "host"); - const char *mount = require_block_string(param, "mount"); - unsigned port = param.GetBlockValue("port", 0u); + const char *host = require_block_string(block, "host"); + const char *mount = require_block_string(block, "mount"); + unsigned port = block.GetBlockValue("port", 0u); if (port == 0) { error.Set(config_domain, "shout port must be configured"); return false; } - const char *passwd = require_block_string(param, "password"); - const char *name = require_block_string(param, "name"); + const char *passwd = require_block_string(block, "password"); + const char *name = require_block_string(block, "name"); - bool is_public = param.GetBlockValue("public", false); + bool is_public = block.GetBlockValue("public", false); - const char *user = param.GetBlockValue("user", "source"); + const char *user = block.GetBlockValue("user", "source"); - const char *value = param.GetBlockValue("quality"); + const char *value = block.GetBlockValue("quality"); if (value != nullptr) { char *test; quality = strtod(value, &test); @@ -141,14 +141,14 @@ ShoutOutput::Configure(const config_param ¶m, Error &error) return false; } - if (param.GetBlockValue("bitrate") != nullptr) { + if (block.GetBlockValue("bitrate") != nullptr) { error.Set(config_domain, "quality and bitrate are " "both defined"); return false; } } else { - value = param.GetBlockValue("bitrate"); + value = block.GetBlockValue("bitrate"); if (value == nullptr) { error.Set(config_domain, "neither bitrate nor quality defined"); @@ -165,7 +165,7 @@ ShoutOutput::Configure(const config_param ¶m, Error &error) } } - const char *encoding = param.GetBlockValue("encoding", "ogg"); + const char *encoding = block.GetBlockValue("encoding", "ogg"); const auto encoder_plugin = shout_encoder_plugin_get(encoding); if (encoder_plugin == nullptr) { error.Format(config_domain, @@ -174,7 +174,7 @@ ShoutOutput::Configure(const config_param ¶m, Error &error) return false; } - encoder = encoder_init(*encoder_plugin, param, error); + encoder = encoder_init(*encoder_plugin, block, error); if (encoder == nullptr) return false; @@ -185,7 +185,7 @@ ShoutOutput::Configure(const config_param ¶m, Error &error) shout_format = SHOUT_FORMAT_OGG; unsigned protocol; - value = param.GetBlockValue("protocol"); + value = block.GetBlockValue("protocol"); if (value != nullptr) { if (0 == strcmp(value, "shoutcast") && 0 != strcmp(encoding, "mp3")) { @@ -226,21 +226,21 @@ ShoutOutput::Configure(const config_param ¶m, Error &error) } /* optional paramters */ - timeout = param.GetBlockValue("timeout", DEFAULT_CONN_TIMEOUT); + timeout = block.GetBlockValue("timeout", DEFAULT_CONN_TIMEOUT); - value = param.GetBlockValue("genre"); + value = block.GetBlockValue("genre"); if (value != nullptr && shout_set_genre(shout_conn, value)) { error.Set(shout_output_domain, shout_get_error(shout_conn)); return false; } - value = param.GetBlockValue("description"); + value = block.GetBlockValue("description"); if (value != nullptr && shout_set_description(shout_conn, value)) { error.Set(shout_output_domain, shout_get_error(shout_conn)); return false; } - value = param.GetBlockValue("url"); + value = block.GetBlockValue("url"); if (value != nullptr && shout_set_url(shout_conn, value)) { error.Set(shout_output_domain, shout_get_error(shout_conn)); return false; @@ -272,15 +272,15 @@ ShoutOutput::Configure(const config_param ¶m, Error &error) } static AudioOutput * -my_shout_init_driver(const config_param ¶m, Error &error) +my_shout_init_driver(const ConfigBlock &block, Error &error) { ShoutOutput *sd = new ShoutOutput(); - if (!sd->Initialize(param, error)) { + if (!sd->Initialize(block, error)) { delete sd; return nullptr; } - if (!sd->Configure(param, error)) { + if (!sd->Configure(block, error)) { delete sd; return nullptr; } -- cgit v1.2.3