diff --git a/src/command/OutputCommands.cxx b/src/command/OutputCommands.cxx index 43d5beeda..bc1b0d766 100644 --- a/src/command/OutputCommands.cxx +++ b/src/command/OutputCommands.cxx @@ -19,8 +19,7 @@ handle_enableoutput(Client &client, Request args, Response &r) auto &partition = client.GetPartition(); - if (!audio_output_enable_index(partition.outputs, - partition.mixer_memento, + if (!audio_output_enable_index(partition, device)) { r.Error(ACK_ERROR_NO_EXIST, "No such audio output"); return CommandResult::ERROR; @@ -37,8 +36,7 @@ handle_disableoutput(Client &client, Request args, Response &r) auto &partition = client.GetPartition(); - if (!audio_output_disable_index(partition.outputs, - partition.mixer_memento, + if (!audio_output_disable_index(partition, device)) { r.Error(ACK_ERROR_NO_EXIST, "No such audio output"); return CommandResult::ERROR; @@ -55,8 +53,7 @@ handle_toggleoutput(Client &client, Request args, Response &r) auto &partition = client.GetPartition(); - if (!audio_output_toggle_index(partition.outputs, - partition.mixer_memento, + if (!audio_output_toggle_index(partition, device)) { r.Error(ACK_ERROR_NO_EXIST, "No such audio output"); return CommandResult::ERROR; diff --git a/src/output/OutputCommand.cxx b/src/output/OutputCommand.cxx index 510fe6b0a..aaba87797 100644 --- a/src/output/OutputCommand.cxx +++ b/src/output/OutputCommand.cxx @@ -9,20 +9,20 @@ */ #include "OutputCommand.hxx" -#include "MultipleOutputs.hxx" #include "Client.hxx" #include "mixer/Mixer.hxx" #include "mixer/Memento.hxx" #include "mixer/Listener.hxx" -#include "Idle.hxx" +#include "IdleFlags.hxx" +#include "Partition.hxx" extern unsigned audio_output_state_version; bool -audio_output_enable_index(MultipleOutputs &outputs, - MixerMemento &mixer_memento, +audio_output_enable_index(Partition &partition, unsigned idx) { + auto &outputs = partition.outputs; if (idx >= outputs.Size()) return false; @@ -30,11 +30,11 @@ audio_output_enable_index(MultipleOutputs &outputs, if (!ao.LockSetEnabled(true)) return true; - idle_add(IDLE_OUTPUT); + partition.EmitIdle(IDLE_OUTPUT); auto *mixer = ao.GetMixer(); if (mixer != nullptr) { - mixer_memento.InvalidateHardwareVolume(); + partition.mixer_memento.InvalidateHardwareVolume(); mixer->listener.OnMixerChanged(); } @@ -46,10 +46,10 @@ audio_output_enable_index(MultipleOutputs &outputs, } bool -audio_output_disable_index(MultipleOutputs &outputs, - MixerMemento &mixer_memento, +audio_output_disable_index(Partition &partition, unsigned idx) { + auto &outputs = partition.outputs; if (idx >= outputs.Size()) return false; @@ -57,12 +57,12 @@ audio_output_disable_index(MultipleOutputs &outputs, if (!ao.LockSetEnabled(false)) return true; - idle_add(IDLE_OUTPUT); + partition.EmitIdle(IDLE_OUTPUT); auto *mixer = ao.GetMixer(); if (mixer != nullptr) { mixer->LockClose(); - mixer_memento.InvalidateHardwareVolume(); + partition.mixer_memento.InvalidateHardwareVolume(); mixer->listener.OnMixerChanged(); } @@ -74,22 +74,22 @@ audio_output_disable_index(MultipleOutputs &outputs, } bool -audio_output_toggle_index(MultipleOutputs &outputs, - MixerMemento &mixer_memento, +audio_output_toggle_index(Partition &partition, unsigned idx) { + auto &outputs = partition.outputs; if (idx >= outputs.Size()) return false; auto &ao = outputs.Get(idx); const bool enabled = ao.LockToggleEnabled(); - idle_add(IDLE_OUTPUT); + partition.EmitIdle(IDLE_OUTPUT); if (!enabled) { auto *mixer = ao.GetMixer(); if (mixer != nullptr) { mixer->LockClose(); - mixer_memento.InvalidateHardwareVolume(); + partition.mixer_memento.InvalidateHardwareVolume(); mixer->listener.OnMixerChanged(); } } diff --git a/src/output/OutputCommand.hxx b/src/output/OutputCommand.hxx index a2ecc9bc4..a8d96e7df 100644 --- a/src/output/OutputCommand.hxx +++ b/src/output/OutputCommand.hxx @@ -1,6 +1,8 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The Music Player Daemon Project +#pragma once + /* * Glue functions for controlling the audio outputs over the MPD * protocol. These functions perform extra validation on all @@ -8,19 +10,14 @@ * */ -#ifndef MPD_OUTPUT_COMMAND_HXX -#define MPD_OUTPUT_COMMAND_HXX - -class MultipleOutputs; -class MixerMemento; +struct Partition; /** * Enables an audio output. Returns false if the specified output * does not exist. */ bool -audio_output_enable_index(MultipleOutputs &outputs, - MixerMemento &mixer_memento, +audio_output_enable_index(Partition &partition, unsigned idx); /** @@ -28,8 +25,7 @@ audio_output_enable_index(MultipleOutputs &outputs, * does not exist. */ bool -audio_output_disable_index(MultipleOutputs &outputs, - MixerMemento &mixer_memento, +audio_output_disable_index(Partition &partition, unsigned idx); /** @@ -37,8 +33,5 @@ audio_output_disable_index(MultipleOutputs &outputs, * does not exist. */ bool -audio_output_toggle_index(MultipleOutputs &outputs, - MixerMemento &mixer_memento, +audio_output_toggle_index(Partition &partition, unsigned idx); - -#endif