From eb771eaf0d123b3aebbad71623938e9d9f8f6d5a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 29 Jan 2018 22:30:56 +0100 Subject: [PATCH] output/Thread: re-lock the mutex after flush error Fixes deadlock due to mutex double lock. --- src/output/Thread.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/output/Thread.cxx b/src/output/Thread.cxx index 3fb17ae54..fe358ce2f 100644 --- a/src/output/Thread.cxx +++ b/src/output/Thread.cxx @@ -379,11 +379,11 @@ PlayFull(FilteredAudioOutput &output, ConstBuffer _buffer) inline void AudioOutputControl::InternalDrain() noexcept { - const ScopeUnlock unlock(mutex); - try { /* flush the filter and play its remaining output */ + const ScopeUnlock unlock(mutex); + while (true) { auto buffer = source.Flush(); if (buffer.IsNull()) @@ -391,14 +391,14 @@ AudioOutputControl::InternalDrain() noexcept PlayFull(*output, buffer); } + + output->Drain(); } catch (...) { FormatError(std::current_exception(), "Failed to flush filter on %s", GetLogName()); InternalCloseError(std::current_exception()); return; } - - output->Drain(); } void