From 6fcddaf8fa5f7c3afda2b69c8d2d377448bd6a50 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 13 Dec 2016 22:15:52 +0100 Subject: [PATCH] output/Thread: use AtScopeExit() to revert the in_playback_loop flag --- src/output/OutputThread.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/output/OutputThread.cxx b/src/output/OutputThread.cxx index 499cb9583..af31e5f9f 100644 --- a/src/output/OutputThread.cxx +++ b/src/output/OutputThread.cxx @@ -35,6 +35,7 @@ #include "thread/Slack.hxx" #include "thread/Name.hxx" #include "util/ConstBuffer.hxx" +#include "util/ScopeExit.hxx" #include "Log.hxx" #include "Compiler.h" @@ -487,6 +488,11 @@ AudioOutput::Play() assert(!in_playback_loop); in_playback_loop = true; + AtScopeExit(this) { + assert(in_playback_loop); + in_playback_loop = false; + }; + while (chunk != nullptr && command == Command::NONE) { if (!PlayChunk(chunk)) break; @@ -495,9 +501,6 @@ AudioOutput::Play() chunk = pipe.Get(); } - assert(in_playback_loop); - in_playback_loop = false; - const ScopeUnlock unlock(mutex); player_control->LockSignal();