From ec52b13449a92abe6025c7765482377c7feec2c0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 14 Oct 2021 13:41:16 +0200 Subject: [PATCH] player/CrossFade: add method IsEnabled() --- src/player/CrossFade.cxx | 4 ++-- src/player/CrossFade.hxx | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/player/CrossFade.cxx b/src/player/CrossFade.cxx index fa99bea65..1f6d4c251 100644 --- a/src/player/CrossFade.cxx +++ b/src/player/CrossFade.cxx @@ -96,8 +96,8 @@ CrossFadeSettings::Calculate(SignedSongTime total_time, { unsigned int chunks = 0; - if (total_time.IsNegative() || - duration <= FloatDuration::zero() || + if (!IsEnabled() || + total_time.IsNegative() || duration >= std::chrono::duration_cast(total_time) || /* we can't crossfade when the audio formats are different */ af != old_format) diff --git a/src/player/CrossFade.hxx b/src/player/CrossFade.hxx index 8ab6ad6ef..1c0f9b082 100644 --- a/src/player/CrossFade.hxx +++ b/src/player/CrossFade.hxx @@ -39,6 +39,10 @@ struct CrossFadeSettings { */ FloatDuration mixramp_delay{-1}; + constexpr bool IsEnabled() const noexcept { + return duration.count() > 0; + } + /** * Calculate how many music pipe chunks should be used for crossfading. *