From 8bfe3497b0909b33b4fdf5a17e80eb45d77fddeb Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Sun, 1 Nov 2009 15:44:56 +0100
Subject: [PATCH] replay_gain: trigger OPTIONS idle event on mode change

---
 doc/protocol.xml   | 6 +++++-
 src/replay_gain.c  | 3 +++
 test/read_tags.c   | 9 +++++++++
 test/run_decoder.c | 9 +++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/protocol.xml b/doc/protocol.xml
index eb48185e9..b6271403a 100644
--- a/doc/protocol.xml
+++ b/doc/protocol.xml
@@ -195,7 +195,7 @@
                 <para>
                   <returnvalue>options</returnvalue>: options like
                   <option>repeat</option>, <option>random</option>,
-                  <option>crossfade</option>
+                  <option>crossfade</option>, replay gain
                 </para>
               </listitem>
             </itemizedlist>
@@ -520,6 +520,10 @@
               seconds, because the new settings does not affect the
               buffered data.
             </para>
+            <para>
+              This command triggers the
+              <returnvalue>options</returnvalue> idle event.
+            </para>
           </listitem>
         </varlistentry>
         <varlistentry id="command_replay_gain_status">
diff --git a/src/replay_gain.c b/src/replay_gain.c
index a59cfa245..020671c8a 100644
--- a/src/replay_gain.c
+++ b/src/replay_gain.c
@@ -24,6 +24,7 @@
 #include "conf.h"
 #include "audio_format.h"
 #include "pcm_volume.h"
+#include "idle.h"
 
 #include <glib.h>
 
@@ -75,6 +76,8 @@ replay_gain_set_mode_string(const char *p)
 	else
 		return false;
 
+	idle_add(IDLE_OPTIONS);
+
 	return true;
 }
 
diff --git a/test/read_tags.c b/test/read_tags.c
index db2221c13..d38183667 100644
--- a/test/read_tags.c
+++ b/test/read_tags.c
@@ -25,6 +25,7 @@
 #include "tag_ape.h"
 #include "tag_id3.h"
 #include "config.h"
+#include "idle.h"
 
 #include <glib.h>
 
@@ -35,6 +36,14 @@
 #include <locale.h>
 #endif
 
+/**
+ * No-op dummy.
+ */
+void
+idle_add(G_GNUC_UNUSED unsigned flags)
+{
+}
+
 /**
  * No-op dummy.
  */
diff --git a/test/run_decoder.c b/test/run_decoder.c
index 861720cdb..3128c6121 100644
--- a/test/run_decoder.c
+++ b/test/run_decoder.c
@@ -22,12 +22,21 @@
 #include "input_stream.h"
 #include "audio_format.h"
 #include "pcm_volume.h"
+#include "idle.h"
 
 #include <glib.h>
 
 #include <assert.h>
 #include <unistd.h>
 
+/**
+ * No-op dummy.
+ */
+void
+idle_add(G_GNUC_UNUSED unsigned flags)
+{
+}
+
 /**
  * No-op dummy.
  */