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/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();