From 5c4743441e2a022a093024b15aedfa60fb1e1e3c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 18 Aug 2022 14:08:30 +0200 Subject: [PATCH 1/3] mixer/All: use Mixer::IsPlugin() --- src/mixer/MixerAll.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mixer/MixerAll.cxx b/src/mixer/MixerAll.cxx index 302a06160..8cf8295e0 100644 --- a/src/mixer/MixerAll.cxx +++ b/src/mixer/MixerAll.cxx @@ -188,8 +188,8 @@ MultipleOutputs::SetSoftwareVolume(unsigned volume) noexcept auto *mixer = ao->GetMixer(); if (mixer != nullptr && - (&mixer->plugin == &software_mixer_plugin || - &mixer->plugin == &null_mixer_plugin)) + (mixer->IsPlugin(software_mixer_plugin) || + mixer->IsPlugin(null_mixer_plugin))) mixer_set_volume(mixer, volume); } } From 2b8f1170a64c33be35d45b79d6c8c3e4eebddf60 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 18 Aug 2022 14:33:19 +0200 Subject: [PATCH 2/3] mixer/Control: use Mixer::IsGlobal() --- src/mixer/MixerControl.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mixer/MixerControl.cxx b/src/mixer/MixerControl.cxx index 51ea759c1..2cc46e501 100644 --- a/src/mixer/MixerControl.cxx +++ b/src/mixer/MixerControl.cxx @@ -92,7 +92,7 @@ mixer_close(Mixer *mixer) void mixer_auto_close(Mixer *mixer) { - if (!mixer->plugin.global) + if (!mixer->IsGlobal()) mixer_close(mixer); } @@ -103,7 +103,7 @@ mixer_get_volume(Mixer *mixer) assert(mixer != nullptr); - if (mixer->plugin.global && !mixer->failure) + if (mixer->IsGlobal() && !mixer->failure) mixer_open(mixer); const std::scoped_lock protect(mixer->mutex); @@ -128,7 +128,7 @@ mixer_set_volume(Mixer *mixer, unsigned volume) assert(mixer != nullptr); assert(volume <= 100); - if (mixer->plugin.global && !mixer->failure) + if (mixer->IsGlobal() && !mixer->failure) mixer_open(mixer); const std::scoped_lock protect(mixer->mutex); From e2d4654e2010f9dbc2f5798319e6170a5da033f1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 18 Aug 2022 14:36:30 +0200 Subject: [PATCH 3/3] filter/ReplayGain: invoke the MixerListener after volume change This ensures that Partition::OnMixerVolumeChanged() invokes MixerMemento::InvalidateHardwareVolume(), clearing the cached volume level. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1526 --- NEWS | 2 ++ src/filter/plugins/ReplayGainFilterPlugin.cxx | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 23f2c41ff..4c36c9b5d 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ ver 0.23.9 (not yet released) - cdio_paranoia: add options "mode" and "skip" * decoder - ffmpeg: support FFmpeg 5.1 +* filter + - replay gain: fix delayed volume display with handler=mixer * output - pipewire: set app icon * fix bogus volume levels with multiple partitions diff --git a/src/filter/plugins/ReplayGainFilterPlugin.cxx b/src/filter/plugins/ReplayGainFilterPlugin.cxx index 3c2f6b351..e89f4af69 100644 --- a/src/filter/plugins/ReplayGainFilterPlugin.cxx +++ b/src/filter/plugins/ReplayGainFilterPlugin.cxx @@ -23,6 +23,8 @@ #include "ReplayGainInfo.hxx" #include "ReplayGainConfig.hxx" #include "mixer/MixerControl.hxx" +#include "mixer/MixerInternal.hxx" +#include "mixer/Listener.hxx" #include "pcm/AudioFormat.hxx" #include "pcm/Volume.hxx" #include "util/ConstBuffer.hxx" @@ -171,9 +173,11 @@ ReplayGainFilter::Update() try { mixer_set_volume(mixer, _volume); - /* TODO: emit this idle event only for the - current partition */ - idle_add(IDLE_MIXER); + /* invoke the mixer's listener manually, just + in case the mixer implementation didn't do + that already (this depends on the + implementation) */ + mixer->listener.OnMixerVolumeChanged(*mixer, _volume); } catch (...) { LogError(std::current_exception(), "Failed to update hardware mixer");