From bc6924d3033346799e4daeb22b7b588c7587165f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 8 Jul 2022 22:53:19 +0200 Subject: [PATCH] output/snapcast: fix busy loop while paused Removing the LockHasClients(); this code was copied from the "httpd" output plugin, but unlike "httpd", the SnapCast output plugin does not feed silence while paused, so we need to implement a delay to avoid busy-looping the CPU. As a side effect, this eliminates the suttering after resuming playback, because the timer now gets reset even if there is a client. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1394 --- NEWS | 2 ++ src/output/plugins/snapcast/SnapcastOutputPlugin.cxx | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 4a9237bc8..80737dc1c 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ ver 0.23.8 (not yet released) - cdio_paranoia: fix crash if no drive was found - cdio_paranoia: faster cancellation - cdio_paranoia: don't scan for replay gain tags + - snapcast: fix busy loop while paused + - snapcast: fix stuttering after resuming playback * mixer - better error messages - alsa: fix setting volume before playback starts diff --git a/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx b/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx index 1abe2a45a..acbb8f92d 100644 --- a/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx +++ b/src/output/plugins/snapcast/SnapcastOutputPlugin.cxx @@ -214,9 +214,8 @@ SnapcastOutput::RemoveClient(SnapcastClient &client) noexcept std::chrono::steady_clock::duration SnapcastOutput::Delay() const noexcept { - if (!LockHasClients() && pause) { - /* if there's no client and this output is paused, - then Pause() will not do anything, it will not fill + if (pause) { + /* Pause() will not do anything, it will not fill the buffer and it will not update the timer; therefore, we reset the timer here */ timer->Reset();