From 4f1e79b6b8cb2f6a4f1fc5c83f181533064862e7 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Tue, 19 Oct 2021 09:51:07 +0200
Subject: [PATCH] filter/ReplayGain: emit "mixer" event when replay gain
 changes volume

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1294
---
 NEWS                                          | 1 +
 src/filter/plugins/ReplayGainFilterPlugin.cxx | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/NEWS b/NEWS
index 5647c4524..2a4aca9d4 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ ver 0.23.1 (not yet released)
   - use decimal notation instead of scientific notation
   - "load" supports relative positions
 * output
+  - emit "mixer" idle event when replay gain changes volume
   - pipewire: emit "mixer" idle events on external volume change
   - pipewire: attempt to change the graph sample rate
   - snapcast: fix time stamp bug which caused "Failed to get chunk"
diff --git a/src/filter/plugins/ReplayGainFilterPlugin.cxx b/src/filter/plugins/ReplayGainFilterPlugin.cxx
index c867640f9..3c2f6b351 100644
--- a/src/filter/plugins/ReplayGainFilterPlugin.cxx
+++ b/src/filter/plugins/ReplayGainFilterPlugin.cxx
@@ -27,6 +27,7 @@
 #include "pcm/Volume.hxx"
 #include "util/ConstBuffer.hxx"
 #include "util/Domain.hxx"
+#include "Idle.hxx"
 #include "Log.hxx"
 
 #include <cassert>
@@ -169,6 +170,10 @@ ReplayGainFilter::Update()
 
 		try {
 			mixer_set_volume(mixer, _volume);
+
+			/* TODO: emit this idle event only for the
+			   current partition */
+			idle_add(IDLE_MIXER);
 		} catch (...) {
 			LogError(std::current_exception(),
 				 "Failed to update hardware mixer");