From ba5531f9dd1f7f22e696d3927f379839d7bdd9fc Mon Sep 17 00:00:00 2001 From: Stapper Date: Fri, 13 Nov 2020 17:35:36 +0100 Subject: [PATCH] Fixes #994 - moveoutput: new AudioOutputControl created from copyMoving an output to a partition is now done via MultipleOutputs::AddCopy(),using a new AudioOutputControl constructor. Tags and always_on settings willpersist when moving outputs between partitions. --- NEWS | 2 ++ src/command/PartitionCommands.cxx | 5 ++--- src/output/Control.cxx | 11 +++++++++++ src/output/Control.hxx | 3 +++ src/output/MultipleOutputs.cxx | 13 +++++++++++++ src/output/MultipleOutputs.hxx | 4 ++++ 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 200998de7..41e926619 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ ver 0.22.4 (not yet released) * decoder - dsdiff: apply padding to odd-sized chunks +* output + - moveoutput: fix always_on and tag lost on move ver 0.22.3 (2020/11/06) * playlist diff --git a/src/command/PartitionCommands.cxx b/src/command/PartitionCommands.cxx index fbcb8a754..9d260425f 100644 --- a/src/command/PartitionCommands.cxx +++ b/src/command/PartitionCommands.cxx @@ -183,9 +183,8 @@ handle_moveoutput(Client &client, Request request, Response &response) existing_output->ReplaceDummy(output->Steal(), was_enabled); else - /* add it to the output list */ - dest_partition.outputs.Add(output->Steal(), - was_enabled); + /* copy the AudioOutputControl and add it to the output list */ + dest_partition.outputs.AddCopy(output,was_enabled); instance.EmitIdle(IDLE_OUTPUT); return CommandResult::OK; diff --git a/src/output/Control.cxx b/src/output/Control.cxx index fd4a1aa50..f05ec29ff 100644 --- a/src/output/Control.cxx +++ b/src/output/Control.cxx @@ -39,6 +39,17 @@ AudioOutputControl::AudioOutputControl(std::unique_ptr _out { } +AudioOutputControl::AudioOutputControl(AudioOutputControl *_output, + AudioOutputClient &_client) noexcept + :output(std::move(_output->Steal())), + name(output->GetName()), + client(_client), + thread(BIND_THIS_METHOD(Task)) +{ + tags =_output->tags; + always_on=_output->always_on; +} + AudioOutputControl::~AudioOutputControl() noexcept { StopThread(); diff --git a/src/output/Control.hxx b/src/output/Control.hxx index 809c65101..ab8637f47 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -245,6 +245,9 @@ public: AudioOutputControl(std::unique_ptr _output, AudioOutputClient &_client) noexcept; + AudioOutputControl(AudioOutputControl *_outputControl, + AudioOutputClient &_client) noexcept; + ~AudioOutputControl() noexcept; AudioOutputControl(const AudioOutputControl &) = delete; diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index 71014e8d1..0639d51c7 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -140,6 +140,19 @@ MultipleOutputs::Add(std::unique_ptr output, client.ApplyEnabled(); } +void +MultipleOutputs::AddCopy(AudioOutputControl *outputControl, + bool enable) noexcept +{ + // TODO: this operation needs to be protected with a mutex + outputs.emplace_back(std::make_unique(outputControl, + client)); + + outputs.back()->LockSetEnabled(enable); + + client.ApplyEnabled(); +} + void MultipleOutputs::EnableDisable() { diff --git a/src/output/MultipleOutputs.hxx b/src/output/MultipleOutputs.hxx index 9c885cb3a..6b3e538c2 100644 --- a/src/output/MultipleOutputs.hxx +++ b/src/output/MultipleOutputs.hxx @@ -128,6 +128,10 @@ public: void Add(std::unique_ptr output, bool enable) noexcept; + void AddCopy(AudioOutputControl *outputControl, + bool enable) noexcept; + + void SetReplayGainMode(ReplayGainMode mode) noexcept; /**