Instance: add method FindOutput()
Move code from handle_moveoutput().
This commit is contained in:
@@ -145,29 +145,24 @@ handle_moveoutput(Client &client, Request request, Response &response)
|
||||
|
||||
/* find the partition which owns this output currently */
|
||||
auto &instance = client.GetInstance();
|
||||
for (auto &partition : instance.partitions) {
|
||||
if (&partition == &dest_partition)
|
||||
continue;
|
||||
|
||||
auto *output = partition.outputs.FindByName(output_name);
|
||||
if (output == nullptr || output->IsDummy())
|
||||
continue;
|
||||
|
||||
const bool was_enabled = output->IsEnabled();
|
||||
|
||||
if (existing_output != nullptr)
|
||||
/* move the output back where it once was */
|
||||
existing_output->ReplaceDummy(output->Steal(),
|
||||
was_enabled);
|
||||
else
|
||||
/* copy the AudioOutputControl and add it to the output list */
|
||||
dest_partition.outputs.AddMoveFrom(std::move(*output),
|
||||
was_enabled);
|
||||
|
||||
instance.EmitIdle(IDLE_OUTPUT);
|
||||
return CommandResult::OK;
|
||||
auto *output = instance.FindOutput(output_name, dest_partition);
|
||||
if (output == nullptr) {
|
||||
response.Error(ACK_ERROR_NO_EXIST, "No such output");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
response.Error(ACK_ERROR_NO_EXIST, "No such output");
|
||||
return CommandResult::ERROR;
|
||||
const bool was_enabled = output->IsEnabled();
|
||||
|
||||
if (existing_output != nullptr)
|
||||
/* move the output back where it once was */
|
||||
existing_output->ReplaceDummy(output->Steal(),
|
||||
was_enabled);
|
||||
else
|
||||
/* copy the AudioOutputControl and add it to the output list */
|
||||
dest_partition.outputs.AddMoveFrom(std::move(*output),
|
||||
was_enabled);
|
||||
|
||||
instance.EmitIdle(IDLE_OUTPUT);
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
Reference in New Issue
Block a user