From 304d45b55133856fc1bff4826f6d548d90b85cb5 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Fri, 31 May 2019 17:23:12 +0200
Subject: [PATCH] Revert "player/Thread: remove unnecessary "pipe" check"

This reverts commit ff3e2c05142c94efadee00812ec348c15f1be1ba.  The
check was necessary, after all, because this is what checked whether
the decoder had finished the current or the next song.

> The "queued" flag can only possibly be set if the decoder is still
> decoding the current song or if the decoder is stopped.

That was wrong because ProcessCommand() sets `queued=true` and also
starts the decoder (if it was idle).

> This is also what the following assert() checks.

That was also wrong, because the assert() has two conditions.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/566
---
 NEWS                  | 1 +
 src/player/Thread.cxx | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index a15642e22..0bc2471eb 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,5 @@
 ver 0.21.10 (not yet released)
+* fix crash bug (0.21.9 regression)
 
 ver 0.21.9 (2019/05/20)
 * input
diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx
index 7d81011f6..028842b61 100644
--- a/src/player/Thread.cxx
+++ b/src/player/Thread.cxx
@@ -996,7 +996,7 @@ Player::Run() noexcept
 			}
 		}
 
-		if (dc.IsIdle() && queued) {
+		if (dc.IsIdle() && queued && IsDecoderAtCurrentSong()) {
 			/* the decoder has finished the current song;
 			   make it decode the next song */