From 0c4bf12bfd61ff6c85af2aeb45f2c6dc10dcb6cd Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Fri, 22 Oct 2021 11:48:46 +0200
Subject: [PATCH] player/CrossFade: fix inverted check and wrong variable

The inverted check was introduced by commit 46d00dd85f8, and commit
8ad17d25ef added a check for the wrong variable.  D'oh!

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1303
---
 NEWS                     | 2 ++
 src/player/CrossFade.cxx | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index b4689cf39..ea141ba62 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ ver 0.23.2 (not yet released)
   - pipewire: DSD support
 * neighbor
   - mention failed plugin name in error message
+* player
+  - fix cross-fade regression
 * fix crash with libfmt versions older than 7
 
 ver 0.23.1 (2021/10/19)
diff --git a/src/player/CrossFade.cxx b/src/player/CrossFade.cxx
index 1eeead4b2..caad86e74 100644
--- a/src/player/CrossFade.cxx
+++ b/src/player/CrossFade.cxx
@@ -34,8 +34,8 @@ inline bool
 CrossFadeSettings::CanCrossFadeSong(SignedSongTime total_time) const noexcept
 {
 	return !total_time.IsNegative() &&
-		duration >= MIN_TOTAL_TIME &&
-		duration >= std::chrono::duration_cast<FloatDuration>(total_time);
+		total_time >= MIN_TOTAL_TIME &&
+		duration < std::chrono::duration_cast<FloatDuration>(total_time);
 }
 
 gcc_pure