Some clients act weird in the face of silence and buffer it rather thay
"playing" it. This causes severe lag when the stream is unpaused.

Stopping clients on mobile devices is also good since it preserves
battery life by allowing them to power down their wireless components
for more power savings.

Signed-off-by: Ben Boeckel <maths...@gmail.com>
---
 doc/mpdconf.example                            |  1 +
 doc/user.xml                                   | 12 ++++++++++++
 src/output/plugins/httpd/HttpdInternal.hxx     |  6 ++++++
 src/output/plugins/httpd/HttpdOutputPlugin.cxx |  4 +++-
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/doc/mpdconf.example b/doc/mpdconf.example
index 2609c38c1..85e8b5615 100644
--- a/doc/mpdconf.example
+++ b/doc/mpdconf.example
@@ -275,6 +275,7 @@ input {
 #      bitrate         "128"                   # do not define if quality is 
defined
 #      format          "44100:16:1"
 #      max_clients     "0"                     # optional 0=no limit
+#      silence_paused  "yes"                   # optional, send silence 
(rather than no data) when paused
 #}
 #
 # An example of a pulseaudio output (streaming to a remote pulseaudio server)
diff --git a/doc/user.xml b/doc/user.xml
index 865369c23..38b77d7be 100644
--- a/doc/user.xml
+++ b/doc/user.xml
@@ -3650,6 +3650,18 @@ run</programlisting>
                   to 0 no limit will apply.
                 </entry>
               </row>
+              <row>
+                <entry>
+                  <varname>silence_paused</varname>
+                  <parameter>PS</parameter>
+                </entry>
+                <entry>
+                  If <literal>true</literal>, silence will be played
+                  while the stream is paused. If <literal>false</literal>, the
+                  stream will send no data, the same behavior for a stopped
+                  stream.
+                </entry>
+              </row>
             </tbody>
           </tgroup>
         </informaltable>
diff --git a/src/output/plugins/httpd/HttpdInternal.hxx 
b/src/output/plugins/httpd/HttpdInternal.hxx
index 762c5385a..745c90173 100644
--- a/src/output/plugins/httpd/HttpdInternal.hxx
+++ b/src/output/plugins/httpd/HttpdInternal.hxx
@@ -130,6 +130,12 @@ private:
         */
        char const *website;
 
+       /**
+        * True if the plugin should play silence when paused rather than not
+        * sending any data.
+        */
+       bool silence_paused;
+
 private:
        /**
         * A linked list containing all clients which are currently
diff --git a/src/output/plugins/httpd/HttpdOutputPlugin.cxx 
b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
index b5c48ea8b..4b42fdf9e 100644
--- a/src/output/plugins/httpd/HttpdOutputPlugin.cxx
+++ b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
@@ -70,6 +70,8 @@ HttpdOutput::HttpdOutput(EventLoop &_loop, const ConfigBlock 
&block)
 
        clients_max = block.GetBlockValue("max_clients", 0u);
 
+       silence_paused = block.GetBlockValue("silence_paused", true);
+
        /* set up bind_to_address */
 
        const char *bind_to_address = block.GetBlockValue("bind_to_address");
@@ -382,7 +384,7 @@ HttpdOutput::Play(const void *chunk, size_t size)
 bool
 HttpdOutput::Pause()
 {
-       if (LockHasClients()) {
+       if (silence_paused && LockHasClients()) {
                static const char silence[1020] = { 0 };
                Play(silence, sizeof(silence));
        }
-- 
2.11.1

_______________________________________________
mpd-devel mailing list
mpd-devel@musicpd.org
http://mailman.blarg.de/listinfo/mpd-devel

Reply via email to