From 2e65686fc08777be1d9caa262e4c6c75805f5960 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 22 May 2017 23:36:45 +0200 Subject: [PATCH] output/Control: add method Configure() Prepare to move some configuration settings from AudioOutput to AudioOutputControl. --- src/output/Control.cxx | 6 ++++++ src/output/Control.hxx | 6 ++++++ src/output/MultipleOutputs.cxx | 13 ++++++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/output/Control.cxx b/src/output/Control.cxx index 59736ecb2..efc7ea5c9 100644 --- a/src/output/Control.cxx +++ b/src/output/Control.cxx @@ -44,6 +44,12 @@ AudioOutputControl::AudioOutputControl(AudioOutput *_output) { } +void +AudioOutputControl::Configure(const ConfigBlock &block) +{ + (void)block; +} + const char * AudioOutputControl::GetName() const { diff --git a/src/output/Control.hxx b/src/output/Control.hxx index 74a90e4d9..bec311274 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -38,6 +38,7 @@ enum class ReplayGainMode : uint8_t; struct AudioOutput; struct MusicChunk; +struct ConfigBlock; class MusicPipe; class Mutex; class Mixer; @@ -158,6 +159,11 @@ public: AudioOutputControl(const AudioOutputControl &) = delete; AudioOutputControl &operator=(const AudioOutputControl &) = delete; + /** + * Throws #std::runtime_error on error. + */ + void Configure(const ConfigBlock &block); + gcc_pure const char *GetName() const; diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index 9aa5087fc..ee3e3aef1 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -75,7 +75,18 @@ LoadOutputControl(EventLoop &event_loop, auto *output = LoadOutput(event_loop, replay_gain_config, mixer_listener, client, block); - return new AudioOutputControl(output); + auto *control = new AudioOutputControl(output); + + try { + control->Configure(block); + } catch (...) { + control->BeginDestroy(); + control->FinishDestroy(); + delete control; + throw; + } + + return control; } void