Commit 7b02c022 authored by Max Kellermann's avatar Max Kellermann

filter/LoadChain: use struct ConfigData

parent 57d77cc8
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "plugins/ChainFilterPlugin.hxx" #include "plugins/ChainFilterPlugin.hxx"
#include "config/Param.hxx" #include "config/Param.hxx"
#include "config/Option.hxx" #include "config/Option.hxx"
#include "config/Global.hxx" #include "config/Data.hxx"
#include "config/Domain.hxx" #include "config/Domain.hxx"
#include "config/Block.hxx" #include "config/Block.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
...@@ -34,10 +34,11 @@ ...@@ -34,10 +34,11 @@
#include <string.h> #include <string.h>
static void static void
filter_chain_append_new(PreparedFilter &chain, const char *template_name) filter_chain_append_new(PreparedFilter &chain, const ConfigData &config,
const char *template_name)
{ {
const auto *cfg = config_find_block(ConfigBlockOption::AUDIO_FILTER, const auto *cfg = config.FindBlock(ConfigBlockOption::AUDIO_FILTER,
"name", template_name); "name", template_name);
if (cfg == nullptr) if (cfg == nullptr)
throw FormatRuntimeError("Filter template not found: %s", throw FormatRuntimeError("Filter template not found: %s",
template_name); template_name);
...@@ -53,7 +54,9 @@ filter_chain_append_new(PreparedFilter &chain, const char *template_name) ...@@ -53,7 +54,9 @@ filter_chain_append_new(PreparedFilter &chain, const char *template_name)
} }
void void
filter_chain_parse(PreparedFilter &chain, const char *spec) filter_chain_parse(PreparedFilter &chain,
const ConfigData &config,
const char *spec)
{ {
const char *const end = spec + strlen(spec); const char *const end = spec + strlen(spec);
...@@ -61,7 +64,7 @@ filter_chain_parse(PreparedFilter &chain, const char *spec) ...@@ -61,7 +64,7 @@ filter_chain_parse(PreparedFilter &chain, const char *spec)
const char *comma = std::find(spec, end, ','); const char *comma = std::find(spec, end, ',');
if (comma > spec) { if (comma > spec) {
const std::string name(spec, comma); const std::string name(spec, comma);
filter_chain_append_new(chain, name.c_str()); filter_chain_append_new(chain, config, name.c_str());
} }
if (comma == end) if (comma == end)
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#ifndef MPD_FILTER_LOAD_CHAIN_HXX #ifndef MPD_FILTER_LOAD_CHAIN_HXX
#define MPD_FILTER_LOAD_CHAIN_HXX #define MPD_FILTER_LOAD_CHAIN_HXX
struct ConfigData;
class PreparedFilter; class PreparedFilter;
/** /**
...@@ -30,9 +31,12 @@ class PreparedFilter; ...@@ -30,9 +31,12 @@ class PreparedFilter;
* Throws std::runtime_error on error. * Throws std::runtime_error on error.
* *
* @param chain the chain to append filters on * @param chain the chain to append filters on
* @param config the global configuration to load filter definitions from
* @param spec the filter chain specification * @param spec the filter chain specification
*/ */
void void
filter_chain_parse(PreparedFilter &chain, const char *spec); filter_chain_parse(PreparedFilter &chain,
const ConfigData &config,
const char *spec);
#endif #endif
...@@ -181,7 +181,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block) ...@@ -181,7 +181,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block)
} }
try { try {
filter_chain_parse(*prepared_filter, filter_chain_parse(*prepared_filter, GetGlobalConfig(),
block.GetBlockValue(AUDIO_FILTERS, "")); block.GetBlockValue(AUDIO_FILTERS, ""));
} catch (...) { } catch (...) {
/* It's not really fatal - Part of the filter chain /* It's not really fatal - Part of the filter chain
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment