diff --git a/src/output/plugins/snapcast/Internal.hxx b/src/output/plugins/snapcast/Internal.hxx index 33fc85b26..e21d3cd94 100644 --- a/src/output/plugins/snapcast/Internal.hxx +++ b/src/output/plugins/snapcast/Internal.hxx @@ -51,6 +51,12 @@ class SnapcastOutput final : AudioOutput, ServerSocket { */ 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; #ifdef HAVE_ZEROCONF diff --git a/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx b/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx index 522943939..73778e6b8 100644 --- a/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx +++ b/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx @@ -161,6 +161,7 @@ SnapcastOutput::Open(AudioFormat &audio_format) timer = new Timer(audio_format); open = true; + pause = false; } void @@ -213,7 +214,7 @@ SnapcastOutput::RemoveClient(SnapcastClient &client) noexcept std::chrono::steady_clock::duration SnapcastOutput::Delay() const noexcept { - if (!LockHasClients() /*&& pause*/) { + if (!LockHasClients() && pause) { /* if there's no client and this output is paused, then Pause() will not do anything, it will not fill the buffer and it will not update the timer; @@ -307,7 +308,7 @@ SnapcastOutput::SendTag(const Tag &tag) size_t SnapcastOutput::Play(const void *chunk, size_t size) { - //pause = false; + pause = false; const auto now = std::chrono::steady_clock::now(); @@ -355,8 +356,7 @@ SnapcastOutput::Play(const void *chunk, size_t size) bool SnapcastOutput::Pause() { - // TODO: implement - //pause = true; + pause = true; return true; }