From 98d76627a5ea5217ad3629d57e475bb5c55034bb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 26 Apr 2018 12:28:10 +0200 Subject: [PATCH] output/alsa: disable events in Cancel() Don't reactivate the PCM device immediately after Cancel() is finished; if Cancel() gets called this may mean that new data may take a while to produce, or no data at all will be produced because the current song is being stopped. Once new data is available, Play() will automatically reactivate the PCM. This fixes underruns when switching songs manually (closes #264). --- src/output/plugins/AlsaOutputPlugin.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 3336117c8..329e458cf 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -779,6 +779,14 @@ AlsaOutput::CancelInternal() noexcept pcm_export->Reset(); period_buffer.Clear(); ClearRingBuffer(); + + { + const std::lock_guard lock(mutex); + active = false; + } + + MultiSocketMonitor::Reset(); + defer_invalidate_sockets.Cancel(); } void