Commit 9a21bdfd authored by Max Kellermann's avatar Max Kellermann

output/snapcast: implement Pause()

This uncomments the code which had been present already in the first Snapcast commit (copied from the "httpd" output plugin), but I commented it because I did not know whether I needed to send silence samples to all Snapcast clients. As a side effect, this fixes playback when no Snapcast client is connected; this was broken because Pause() always returned a positive value when there were no clients. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1310
parent 03f99dd2
...@@ -51,6 +51,12 @@ class SnapcastOutput final : AudioOutput, ServerSocket { ...@@ -51,6 +51,12 @@ class SnapcastOutput final : AudioOutput, ServerSocket {
*/ */
bool open; bool open;
/**
* Is the output current paused? This is set by Pause() and
* is cleared by the next Play() call. It is used in Delay().
*/
bool pause;
InjectEvent inject_event; InjectEvent inject_event;
#ifdef HAVE_ZEROCONF #ifdef HAVE_ZEROCONF
......
...@@ -161,6 +161,7 @@ SnapcastOutput::Open(AudioFormat &audio_format) ...@@ -161,6 +161,7 @@ SnapcastOutput::Open(AudioFormat &audio_format)
timer = new Timer(audio_format); timer = new Timer(audio_format);
open = true; open = true;
pause = false;
} }
void void
...@@ -213,7 +214,7 @@ SnapcastOutput::RemoveClient(SnapcastClient &client) noexcept ...@@ -213,7 +214,7 @@ SnapcastOutput::RemoveClient(SnapcastClient &client) noexcept
std::chrono::steady_clock::duration std::chrono::steady_clock::duration
SnapcastOutput::Delay() const noexcept SnapcastOutput::Delay() const noexcept
{ {
if (!LockHasClients() /*&& pause*/) { if (!LockHasClients() && pause) {
/* if there's no client and this output is paused, /* if there's no client and this output is paused,
then Pause() will not do anything, it will not fill then Pause() will not do anything, it will not fill
the buffer and it will not update the timer; the buffer and it will not update the timer;
...@@ -307,7 +308,7 @@ SnapcastOutput::SendTag(const Tag &tag) ...@@ -307,7 +308,7 @@ SnapcastOutput::SendTag(const Tag &tag)
size_t size_t
SnapcastOutput::Play(const void *chunk, size_t size) SnapcastOutput::Play(const void *chunk, size_t size)
{ {
//pause = false; pause = false;
const auto now = std::chrono::steady_clock::now(); const auto now = std::chrono::steady_clock::now();
...@@ -355,8 +356,7 @@ SnapcastOutput::Play(const void *chunk, size_t size) ...@@ -355,8 +356,7 @@ SnapcastOutput::Play(const void *chunk, size_t size)
bool bool
SnapcastOutput::Pause() SnapcastOutput::Pause()
{ {
// TODO: implement pause = true;
//pause = true;
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment