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
This commit is contained in:
parent
03f99dd26e
commit
9a21bdfd6a
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user