From 2d0382328315630321c4cd4c20c7708e00ef5982 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 22 Oct 2021 20:18:06 +0200 Subject: [PATCH] output/Control: fold Configure() into the constructor --- src/output/Control.cxx | 16 ++++++---------- src/output/Control.hxx | 11 +++++------ src/output/MultipleOutputs.cxx | 5 ++--- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/output/Control.cxx b/src/output/Control.cxx index 1da9fe1f4..7fc5d74b1 100644 --- a/src/output/Control.cxx +++ b/src/output/Control.cxx @@ -33,11 +33,15 @@ static constexpr PeriodClock::Duration REOPEN_AFTER = std::chrono::seconds(10); AudioOutputControl::AudioOutputControl(std::unique_ptr _output, - AudioOutputClient &_client) noexcept + AudioOutputClient &_client, + const ConfigBlock &block) :output(std::move(_output)), name(output->GetName()), client(_client), - thread(BIND_THIS_METHOD(Task)) + thread(BIND_THIS_METHOD(Task)), + tags(block.GetBlockValue("tags", true)), + always_on(block.GetBlockValue("always_on", false)), + enabled(block.GetBlockValue("enabled", true)) { } @@ -57,14 +61,6 @@ AudioOutputControl::~AudioOutputControl() noexcept StopThread(); } -void -AudioOutputControl::Configure(const ConfigBlock &block) -{ - tags = block.GetBlockValue("tags", true); - always_on = block.GetBlockValue("always_on", false); - enabled = block.GetBlockValue("enabled", true); -} - std::unique_ptr AudioOutputControl::Steal() noexcept { diff --git a/src/output/Control.hxx b/src/output/Control.hxx index d2a341bb4..bc15555d9 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -249,8 +249,12 @@ public: */ mutable Mutex mutex; + /** + * Throws on error. + */ AudioOutputControl(std::unique_ptr _output, - AudioOutputClient &_client) noexcept; + AudioOutputClient &_client, + const ConfigBlock &block); /** * Move the contents of an existing instance, and convert that @@ -264,11 +268,6 @@ public: AudioOutputControl(const AudioOutputControl &) = delete; AudioOutputControl &operator=(const AudioOutputControl &) = delete; - /** - * Throws on error. - */ - void Configure(const ConfigBlock &block); - [[gnu::pure]] const char *GetName() const noexcept; diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index d2806e7f8..f7d0fbcd7 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -80,9 +80,8 @@ LoadOutputControl(EventLoop &event_loop, EventLoop &rt_event_loop, replay_gain_config, mixer_listener, block, defaults, filter_factory); - auto control = std::make_unique(std::move(output), client); - control->Configure(block); - return control; + return std::make_unique(std::move(output), + client, block); } void