diff --git a/src/command/PartitionCommands.cxx b/src/command/PartitionCommands.cxx index 2d221feab..10426a2b2 100644 --- a/src/command/PartitionCommands.cxx +++ b/src/command/PartitionCommands.cxx @@ -186,7 +186,8 @@ handle_moveoutput(Client &client, Request request, Response &response) was_enabled); else /* copy the AudioOutputControl and add it to the output list */ - dest_partition.outputs.AddCopy(output,was_enabled); + dest_partition.outputs.AddMoveFrom(std::move(*output), + was_enabled); instance.EmitIdle(IDLE_OUTPUT); return CommandResult::OK; diff --git a/src/output/Control.cxx b/src/output/Control.cxx index d6f49555f..57d45f229 100644 --- a/src/output/Control.cxx +++ b/src/output/Control.cxx @@ -41,15 +41,15 @@ AudioOutputControl::AudioOutputControl(std::unique_ptr _out { } -AudioOutputControl::AudioOutputControl(AudioOutputControl *_output, +AudioOutputControl::AudioOutputControl(AudioOutputControl &&src, AudioOutputClient &_client) noexcept - :output(_output->Steal()), + :output(src.Steal()), name(output->GetName()), client(_client), thread(BIND_THIS_METHOD(Task)) { - tags =_output->tags; - always_on=_output->always_on; + tags = src.tags; + always_on = src.always_on; } AudioOutputControl::~AudioOutputControl() noexcept diff --git a/src/output/Control.hxx b/src/output/Control.hxx index 01009b7ae..d2a341bb4 100644 --- a/src/output/Control.hxx +++ b/src/output/Control.hxx @@ -252,7 +252,11 @@ public: AudioOutputControl(std::unique_ptr _output, AudioOutputClient &_client) noexcept; - AudioOutputControl(AudioOutputControl *_outputControl, + /** + * Move the contents of an existing instance, and convert that + * existing instance to a "dummy" output. + */ + AudioOutputControl(AudioOutputControl &&src, AudioOutputClient &_client) noexcept; ~AudioOutputControl() noexcept; diff --git a/src/output/MultipleOutputs.cxx b/src/output/MultipleOutputs.cxx index ab9d3c66f..77fbabab5 100644 --- a/src/output/MultipleOutputs.cxx +++ b/src/output/MultipleOutputs.cxx @@ -143,11 +143,12 @@ MultipleOutputs::Add(std::unique_ptr output, } void -MultipleOutputs::AddCopy(AudioOutputControl *outputControl, - bool enable) noexcept +MultipleOutputs::AddMoveFrom(AudioOutputControl &&src, + bool enable) noexcept { // TODO: this operation needs to be protected with a mutex - outputs.push_back(std::make_unique(outputControl, client)); + outputs.push_back(std::make_unique(std::move(src), + client)); outputs.back()->LockSetEnabled(enable); diff --git a/src/output/MultipleOutputs.hxx b/src/output/MultipleOutputs.hxx index 9e101bb0a..3bf492d47 100644 --- a/src/output/MultipleOutputs.hxx +++ b/src/output/MultipleOutputs.hxx @@ -128,8 +128,8 @@ public: void Add(std::unique_ptr output, bool enable) noexcept; - void AddCopy(AudioOutputControl *outputControl, - bool enable) noexcept; + void AddMoveFrom(AudioOutputControl &&src, + bool enable) noexcept; void SetReplayGainMode(ReplayGainMode mode) noexcept;