Ben Boeckel
2015-10-27 02:40:50 UTC
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 <***@gmail.com>
---
doc/mpdconf.example | 1 +
doc/user.xml | 10 ++++++++++
src/output/plugins/httpd/HttpdInternal.hxx | 5 +++++
src/output/plugins/httpd/HttpdOutputPlugin.cxx | 4 +++-
4 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/doc/mpdconf.example b/doc/mpdconf.example
index 87d3021..781c3a9 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
+# play_silence "yes" # optional, play silence 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 f66f6e3..af6b3af 100644
--- a/doc/user.xml
+++ b/doc/user.xml
@@ -2846,6 +2846,16 @@ buffer_size: 16384</programlisting>
to 0 no limit will apply.
</entry>
</row>
+ <row>
+ <entry>
+ <varname>play_silence</varname>
+ <parameter>PS</parameter>
+ </entry>
+ <entry>
+ If <literal>true</literal>, silence will be played
+ while the stream is paused.
+ </entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
diff --git a/src/output/plugins/httpd/HttpdInternal.hxx b/src/output/plugins/httpd/HttpdInternal.hxx
index 01498df..bb87ed4 100644
--- a/src/output/plugins/httpd/HttpdInternal.hxx
+++ b/src/output/plugins/httpd/HttpdInternal.hxx
@@ -125,6 +125,11 @@ private:
*/
char const *website;
+ /**
+ * True if the plugin should play silence when paused.
+ */
+ bool play_silence;
+
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 765a72d..78a4088 100644
--- a/src/output/plugins/httpd/HttpdOutputPlugin.cxx
+++ b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
@@ -113,6 +113,8 @@ HttpdOutput::Configure(const ConfigBlock &block, Error &error)
clients_max = block.GetBlockValue("max_clients", 0u);
+ play_silence = block.GetBlockValue("play_silence", true);
+
/* set up bind_to_address */
const char *bind_to_address = block.GetBlockValue("bind_to_address");
@@ -481,7 +483,7 @@ httpd_output_pause(AudioOutput *ao)
{
HttpdOutput *httpd = HttpdOutput::Cast(ao);
- if (httpd->LockHasClients()) {
+ if (httpd->play_silence && httpd->LockHasClients()) {
static const char silence[1020] = { 0 };
return httpd_output_play(ao, silence, sizeof(silence),
IgnoreError()) > 0;
"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 <***@gmail.com>
---
doc/mpdconf.example | 1 +
doc/user.xml | 10 ++++++++++
src/output/plugins/httpd/HttpdInternal.hxx | 5 +++++
src/output/plugins/httpd/HttpdOutputPlugin.cxx | 4 +++-
4 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/doc/mpdconf.example b/doc/mpdconf.example
index 87d3021..781c3a9 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
+# play_silence "yes" # optional, play silence 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 f66f6e3..af6b3af 100644
--- a/doc/user.xml
+++ b/doc/user.xml
@@ -2846,6 +2846,16 @@ buffer_size: 16384</programlisting>
to 0 no limit will apply.
</entry>
</row>
+ <row>
+ <entry>
+ <varname>play_silence</varname>
+ <parameter>PS</parameter>
+ </entry>
+ <entry>
+ If <literal>true</literal>, silence will be played
+ while the stream is paused.
+ </entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
diff --git a/src/output/plugins/httpd/HttpdInternal.hxx b/src/output/plugins/httpd/HttpdInternal.hxx
index 01498df..bb87ed4 100644
--- a/src/output/plugins/httpd/HttpdInternal.hxx
+++ b/src/output/plugins/httpd/HttpdInternal.hxx
@@ -125,6 +125,11 @@ private:
*/
char const *website;
+ /**
+ * True if the plugin should play silence when paused.
+ */
+ bool play_silence;
+
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 765a72d..78a4088 100644
--- a/src/output/plugins/httpd/HttpdOutputPlugin.cxx
+++ b/src/output/plugins/httpd/HttpdOutputPlugin.cxx
@@ -113,6 +113,8 @@ HttpdOutput::Configure(const ConfigBlock &block, Error &error)
clients_max = block.GetBlockValue("max_clients", 0u);
+ play_silence = block.GetBlockValue("play_silence", true);
+
/* set up bind_to_address */
const char *bind_to_address = block.GetBlockValue("bind_to_address");
@@ -481,7 +483,7 @@ httpd_output_pause(AudioOutput *ao)
{
HttpdOutput *httpd = HttpdOutput::Cast(ao);
- if (httpd->LockHasClients()) {
+ if (httpd->play_silence && httpd->LockHasClients()) {
static const char silence[1020] = { 0 };
return httpd_output_play(ao, silence, sizeof(silence),
IgnoreError()) > 0;
--
2.6.2
2.6.2