From 2518612b1b26efb499495efa3120ab4667c6f691 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 3 Dec 2021 23:22:49 +0100 Subject: [PATCH] player/CrossFade: add method IsMixRampEnabled() --- src/player/CrossFade.cxx | 2 +- src/player/CrossFade.hxx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/player/CrossFade.cxx b/src/player/CrossFade.cxx index caad86e74..d61c0d0a5 100644 --- a/src/player/CrossFade.cxx +++ b/src/player/CrossFade.cxx @@ -118,7 +118,7 @@ CrossFadeSettings::Calculate(SignedSongTime current_total_time, const auto chunk_duration = af.SizeToTime(sizeof(MusicChunk::data)); - if (mixramp_delay <= FloatDuration::zero() || + if (!IsMixRampEnabled() || !mixramp_start || !mixramp_prev_end) { chunks = lround(duration / chunk_duration); } else { diff --git a/src/player/CrossFade.hxx b/src/player/CrossFade.hxx index 8afda835c..38e919666 100644 --- a/src/player/CrossFade.hxx +++ b/src/player/CrossFade.hxx @@ -48,6 +48,10 @@ struct CrossFadeSettings { return duration.count() > 0; } + constexpr bool IsMixRampEnabled() const noexcept { + return mixramp_delay > FloatDuration::zero(); + } + /** * Calculate how many music pipe chunks should be used for crossfading. *