output/Thread: use AtScopeExit() to revert the in_playback_loop flag

This commit is contained in:
Max Kellermann 2016-12-13 22:15:52 +01:00
parent 41fd583fbc
commit 6fcddaf8fa
1 changed files with 6 additions and 3 deletions

View File

@ -35,6 +35,7 @@
#include "thread/Slack.hxx" #include "thread/Slack.hxx"
#include "thread/Name.hxx" #include "thread/Name.hxx"
#include "util/ConstBuffer.hxx" #include "util/ConstBuffer.hxx"
#include "util/ScopeExit.hxx"
#include "Log.hxx" #include "Log.hxx"
#include "Compiler.h" #include "Compiler.h"
@ -487,6 +488,11 @@ AudioOutput::Play()
assert(!in_playback_loop); assert(!in_playback_loop);
in_playback_loop = true; in_playback_loop = true;
AtScopeExit(this) {
assert(in_playback_loop);
in_playback_loop = false;
};
while (chunk != nullptr && command == Command::NONE) { while (chunk != nullptr && command == Command::NONE) {
if (!PlayChunk(chunk)) if (!PlayChunk(chunk))
break; break;
@ -495,9 +501,6 @@ AudioOutput::Play()
chunk = pipe.Get(); chunk = pipe.Get();
} }
assert(in_playback_loop);
in_playback_loop = false;
const ScopeUnlock unlock(mutex); const ScopeUnlock unlock(mutex);
player_control->LockSignal(); player_control->LockSignal();