From ac74f284aa46e83794f11b78d5776ae6b685f11e Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Fri, 5 Apr 2019 10:30:52 +0200
Subject: [PATCH] decoder/Bridge: check for STOP before InputStream::IsReady()

If the DecoderThread gets woken up by a STOP command, this should be
detected as early as possible.
---
 src/decoder/Bridge.cxx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx
index a03f1779c..1a695cede 100644
--- a/src/decoder/Bridge.cxx
+++ b/src/decoder/Bridge.cxx
@@ -368,15 +368,15 @@ DecoderBridge::OpenUri(const char *uri)
 
 	const std::lock_guard<Mutex> lock(mutex);
 	while (true) {
+		if (dc.command == DecoderCommand::STOP)
+			throw StopDecoder();
+
 		is->Update();
 		if (is->IsReady()) {
 			is->Check();
 			return is;
 		}
 
-		if (dc.command == DecoderCommand::STOP)
-			throw StopDecoder();
-
 		cond.wait(mutex);
 	}
 }