Commit 2d038232 authored by Max Kellermann's avatar Max Kellermann

output/Control: fold Configure() into the constructor

parent bba144ec
......@@ -33,11 +33,15 @@
static constexpr PeriodClock::Duration REOPEN_AFTER = std::chrono::seconds(10);
AudioOutputControl::AudioOutputControl(std::unique_ptr<FilteredAudioOutput> _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<FilteredAudioOutput>
AudioOutputControl::Steal() noexcept
{
......
......@@ -249,8 +249,12 @@ public:
*/
mutable Mutex mutex;
/**
* Throws on error.
*/
AudioOutputControl(std::unique_ptr<FilteredAudioOutput> _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;
......
......@@ -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<AudioOutputControl>(std::move(output), client);
control->Configure(block);
return control;
return std::make_unique<AudioOutputControl>(std::move(output),
client, block);
}
void
......
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