From 8a809013f36fe11b7c8b05d091895418f497552b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 26 Apr 2018 16:14:27 +0200 Subject: [PATCH] output/alsa: reset "active" on error Use the "active" flag in PrepareSockets() instead of LockHasError(). --- src/output/plugins/AlsaOutputPlugin.cxx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 70d9360d7..3336117c8 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -305,14 +305,10 @@ private: return frames_written; } - bool LockHasError() const noexcept { - const std::lock_guard lock(mutex); - return !!error; - } - void LockCaughtError() noexcept { const std::lock_guard lock(mutex); error = std::current_exception(); + active = false; cond.signal(); } @@ -766,12 +762,11 @@ AlsaOutput::Drain() Activate(); - while (drain) { - if (error) - std::rethrow_exception(error); - + while (drain && active) cond.wait(mutex); - } + + if (error) + std::rethrow_exception(error); } inline void @@ -866,7 +861,7 @@ AlsaOutput::Play(const void *chunk, size_t size) std::chrono::steady_clock::duration AlsaOutput::PrepareSockets() noexcept { - if (LockHasError()) { + if (!LockIsActive()) { ClearSocketList(); return std::chrono::steady_clock::duration(-1); }