diff options
author | Max Kellermann <max@musicpd.org> | 2018-08-18 20:57:02 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-08-18 20:57:02 +0200 |
commit | 4531e4cc55fa57964a3014fd65877ead3c23fa5d (patch) | |
tree | 7ee3cb6f3a25452739635a39bf4ede97825ea677 /src/output | |
parent | 1ba35e1fd4871f2430d7f3bf5a799f2ad39f73ab (diff) |
filter/LoadChain: move code to class FilterFactory
Eliminate a use of GetGlobalConfig().
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/Filtered.hxx | 8 | ||||
-rw-r--r-- | src/output/Init.cxx | 17 | ||||
-rw-r--r-- | src/output/MultipleOutputs.cxx | 19 |
3 files changed, 30 insertions, 14 deletions
diff --git a/src/output/Filtered.hxx b/src/output/Filtered.hxx index ed9d51e71..4068763d6 100644 --- a/src/output/Filtered.hxx +++ b/src/output/Filtered.hxx @@ -28,6 +28,7 @@ #include <map> #include <chrono> +class FilterFactory; class PreparedFilter; class MusicPipe; class EventLoop; @@ -127,12 +128,14 @@ public: */ FilteredAudioOutput(const char *_plugin_name, std::unique_ptr<AudioOutput> &&_output, - const ConfigBlock &block); + const ConfigBlock &block, + FilterFactory *filter_factory); ~FilteredAudioOutput(); private: - void Configure(const ConfigBlock &block); + void Configure(const ConfigBlock &block, + FilterFactory *filter_factory); public: void Setup(EventLoop &event_loop, @@ -235,6 +238,7 @@ std::unique_ptr<FilteredAudioOutput> audio_output_new(EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, const ConfigBlock &block, + FilterFactory *filter_factory, MixerListener &mixer_listener); #endif diff --git a/src/output/Init.cxx b/src/output/Init.cxx index 784a605c8..0924a0f00 100644 --- a/src/output/Init.cxx +++ b/src/output/Init.cxx @@ -54,10 +54,11 @@ FilteredAudioOutput::FilteredAudioOutput(const char *_plugin_name, std::unique_ptr<AudioOutput> &&_output, - const ConfigBlock &block) + const ConfigBlock &block, + FilterFactory *filter_factory) :plugin_name(_plugin_name), output(std::move(_output)) { - Configure(block); + Configure(block, filter_factory); } static const AudioOutputPlugin * @@ -148,7 +149,8 @@ audio_output_load_mixer(EventLoop &event_loop, FilteredAudioOutput &ao, } void -FilteredAudioOutput::Configure(const ConfigBlock &block) +FilteredAudioOutput::Configure(const ConfigBlock &block, + FilterFactory *filter_factory) { if (!block.IsNull()) { name = block.GetBlockValue(AUDIO_OUTPUT_NAME); @@ -181,8 +183,9 @@ FilteredAudioOutput::Configure(const ConfigBlock &block) } try { - filter_chain_parse(*prepared_filter, GetGlobalConfig(), - block.GetBlockValue(AUDIO_FILTERS, "")); + if (filter_factory != nullptr) + filter_chain_parse(*prepared_filter, *filter_factory, + block.GetBlockValue(AUDIO_FILTERS, "")); } catch (...) { /* It's not really fatal - Part of the filter chain has been set up already and even an empty one will @@ -256,6 +259,7 @@ std::unique_ptr<FilteredAudioOutput> audio_output_new(EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, const ConfigBlock &block, + FilterFactory *filter_factory, MixerListener &mixer_listener) { const AudioOutputPlugin *plugin; @@ -286,7 +290,8 @@ audio_output_new(EventLoop &event_loop, assert(ao != nullptr); auto f = std::make_unique<FilteredAudioOutput>(plugin->name, - std::move(ao), block); + std::move(ao), block, + filter_factory); f->Setup(event_loop, replay_gain_config, plugin->mixer_plugin, mixer_listener, block); diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index af21d2e33..6c9acee9e 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -23,6 +23,7 @@ #include "Domain.hxx" #include "MusicPipe.hxx" #include "MusicChunk.hxx" +#include "filter/Factory.hxx" #include "config/Block.hxx" #include "config/Data.hxx" #include "config/Option.hxx" @@ -51,9 +52,11 @@ static std::unique_ptr<FilteredAudioOutput> LoadOutput(EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, MixerListener &mixer_listener, - const ConfigBlock &block) + const ConfigBlock &block, + FilterFactory *filter_factory) try { return audio_output_new(event_loop, replay_gain_config, block, + filter_factory, mixer_listener); } catch (...) { if (block.line > 0) @@ -67,11 +70,12 @@ static AudioOutputControl * LoadOutputControl(EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, MixerListener &mixer_listener, - AudioOutputClient &client, const ConfigBlock &block) + AudioOutputClient &client, const ConfigBlock &block, + FilterFactory *filter_factory) { auto output = LoadOutput(event_loop, replay_gain_config, mixer_listener, - block); + block, filter_factory); auto *control = new AudioOutputControl(std::move(output), client); try { @@ -91,12 +95,14 @@ MultipleOutputs::Configure(EventLoop &event_loop, const ReplayGainConfig &replay_gain_config, AudioOutputClient &client) { + FilterFactory filter_factory(config); + for (const auto &block : config.GetBlockList(ConfigBlockOption::AUDIO_OUTPUT)) { block.SetUsed(); auto *output = LoadOutputControl(event_loop, replay_gain_config, mixer_listener, - client, block); + client, block, &filter_factory); if (FindByName(output->GetName()) != nullptr) throw FormatRuntimeError("output devices with identical " "names: %s", output->GetName()); @@ -110,7 +116,8 @@ MultipleOutputs::Configure(EventLoop &event_loop, auto *output = LoadOutputControl(event_loop, replay_gain_config, mixer_listener, - client, empty); + client, empty, + nullptr); outputs.push_back(output); } } @@ -125,7 +132,7 @@ MultipleOutputs::AddNullOutput(EventLoop &event_loop, auto *output = LoadOutputControl(event_loop, replay_gain_config, mixer_listener, - client, block); + client, block, nullptr); outputs.push_back(output); } |