From 9b1fbdbca63f03c357a2f9c01fca281f62b3570c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 24 Jan 2014 16:55:17 +0100 Subject: ConfigGlobal: add config_find_block() Merge duplicate code. --- src/decoder/DecoderList.cxx | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) (limited to 'src/decoder/DecoderList.cxx') diff --git a/src/decoder/DecoderList.cxx b/src/decoder/DecoderList.cxx index 5423a85ab..5d9d44d34 100644 --- a/src/decoder/DecoderList.cxx +++ b/src/decoder/DecoderList.cxx @@ -43,7 +43,6 @@ #include "plugins/MpcdecDecoderPlugin.hxx" #include "plugins/FluidsynthDecoderPlugin.hxx" #include "plugins/SidplayDecoderPlugin.hxx" -#include "system/FatalError.hxx" #include "util/Macros.hxx" #include @@ -126,30 +125,6 @@ decoder_plugin_from_name(const char *name) }); } -/** - * Find the "decoder" configuration block for the specified plugin. - * - * @param plugin_name the name of the decoder plugin - * @return the configuration block, or nullptr if none was configured - */ -static const struct config_param * -decoder_plugin_config(const char *plugin_name) -{ - const struct config_param *param = nullptr; - - while ((param = config_get_next_param(CONF_DECODER, param)) != nullptr) { - const char *name = param->GetBlockValue("plugin"); - if (name == nullptr) - FormatFatalError("decoder configuration without 'plugin' name in line %d", - param->line); - - if (strcmp(name, plugin_name) == 0) - return param; - } - - return nullptr; -} - void decoder_plugin_init_all(void) { struct config_param empty; @@ -157,7 +132,7 @@ void decoder_plugin_init_all(void) for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i) { const DecoderPlugin &plugin = *decoder_plugins[i]; const struct config_param *param = - decoder_plugin_config(plugin.name); + config_find_block(CONF_DECODER, "plugin", plugin.name); if (param == nullptr) param = ∅ -- cgit v1.2.3