OutputCommands get ride of global mixer idle events

This commit is contained in:
jcorporation 2022-09-06 21:58:18 +02:00
parent b2fb920d28
commit 310a146a55
5 changed files with 16 additions and 4 deletions

View File

@ -225,6 +225,13 @@ Partition::OnMixerVolumeChanged(Mixer &, int) noexcept
EmitIdle(IDLE_MIXER);
}
void
Partition::OnMixerChanged() noexcept
{
/* notify clients */
EmitIdle(IDLE_MIXER);
}
void
Partition::OnIdleMonitor(unsigned mask) noexcept
{

View File

@ -288,6 +288,7 @@ private:
/* virtual methods from class MixerListener */
void OnMixerVolumeChanged(Mixer &mixer, int volume) noexcept override;
void OnMixerChanged() noexcept override;
/* callback for #idle_monitor */
void OnIdleMonitor(unsigned mask) noexcept;

View File

@ -30,6 +30,7 @@ class MixerListener {
public:
virtual void OnMixerVolumeChanged(Mixer &mixer,
int volume) noexcept = 0;
virtual void OnMixerChanged() noexcept = 0;
};
#endif

View File

@ -29,6 +29,7 @@
#include "Client.hxx"
#include "mixer/Mixer.hxx"
#include "mixer/Memento.hxx"
#include "mixer/Listener.hxx"
#include "Idle.hxx"
extern unsigned audio_output_state_version;
@ -47,9 +48,10 @@ audio_output_enable_index(MultipleOutputs &outputs,
idle_add(IDLE_OUTPUT);
if (ao.GetMixer() != nullptr) {
auto *mixer = ao.GetMixer();
if (mixer != nullptr) {
mixer_memento.InvalidateHardwareVolume();
idle_add(IDLE_MIXER);
mixer->listener.OnMixerChanged();
}
ao.GetClient().ApplyEnabled();
@ -77,7 +79,7 @@ audio_output_disable_index(MultipleOutputs &outputs,
if (mixer != nullptr) {
mixer->LockClose();
mixer_memento.InvalidateHardwareVolume();
idle_add(IDLE_MIXER);
mixer->listener.OnMixerChanged();
}
ao.GetClient().ApplyEnabled();
@ -104,7 +106,7 @@ audio_output_toggle_index(MultipleOutputs &outputs,
if (mixer != nullptr) {
mixer->LockClose();
mixer_memento.InvalidateHardwareVolume();
idle_add(IDLE_MIXER);
mixer->listener.OnMixerChanged();
}
}

View File

@ -25,6 +25,7 @@
class NullMixerListener : public MixerListener {
public:
void OnMixerVolumeChanged(Mixer &, int) noexcept override {}
virtual void OnMixerChanged() noexcept override {}
};
#endif