aboutsummaryrefslogtreecommitdiffstats
path: root/src/filter/FilterConfig.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-24 16:55:17 +0100
committerMax Kellermann <max@duempel.org>2014-01-24 16:55:17 +0100
commit9b1fbdbca63f03c357a2f9c01fca281f62b3570c (patch)
treef093e063f77625e1380e7b1e8f5654a4be254d85 /src/filter/FilterConfig.cxx
parent97391fd4b975eab7049c31c88b8a118be430c427 (diff)
downloadmpd-9b1fbdbca63f03c357a2f9c01fca281f62b3570c.tar.gz
mpd-9b1fbdbca63f03c357a2f9c01fca281f62b3570c.tar.xz
mpd-9b1fbdbca63f03c357a2f9c01fca281f62b3570c.zip
ConfigGlobal: add config_find_block()
Merge duplicate code.
Diffstat (limited to 'src/filter/FilterConfig.cxx')
-rw-r--r--src/filter/FilterConfig.cxx40
1 files changed, 6 insertions, 34 deletions
diff --git a/src/filter/FilterConfig.cxx b/src/filter/FilterConfig.cxx
index 5f2c3a95b..d8c1fc6c2 100644
--- a/src/filter/FilterConfig.cxx
+++ b/src/filter/FilterConfig.cxx
@@ -31,45 +31,17 @@
#include <string.h>
-/**
- * Find the "filter" configuration block for the specified name.
- *
- * @param filter_template_name the name of the filter template
- * @param error space to return an error description
- * @return the configuration block, or nullptr if none was configured
- */
-static const struct config_param *
-filter_plugin_config(const char *filter_template_name, Error &error)
-{
- const struct config_param *param = nullptr;
-
- while ((param = config_get_next_param(CONF_AUDIO_FILTER, param)) != nullptr) {
- const char *name = param->GetBlockValue("name");
- if (name == nullptr) {
- error.Format(config_domain,
- "filter configuration without 'name' name in line %d",
- param->line);
- return nullptr;
- }
-
- if (strcmp(name, filter_template_name) == 0)
- return param;
- }
-
- error.Format(config_domain,
- "filter template not found: %s",
- filter_template_name);
- return nullptr;
-}
-
static bool
filter_chain_append_new(Filter &chain, const char *template_name, Error &error)
{
const struct config_param *cfg =
- filter_plugin_config(template_name, error);
- if (cfg == nullptr)
- // The error has already been set, just stop.
+ config_find_block(CONF_AUDIO_FILTER, "name", template_name);
+ if (cfg == nullptr) {
+ error.Format(config_domain,
+ "filter template not found: %s",
+ template_name);
return false;
+ }
// Instantiate one of those filter plugins with the template name as a hint
Filter *f = filter_configured_new(*cfg, error);