aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-30 17:06:40 +0100
committerMax Kellermann <max@duempel.org>2013-10-30 17:20:12 +0100
commitc6f101884b282a938c9c996ff613153520367b2a (patch)
tree63e7d311c500281c7a451f86f0cc433d9233e24a /src
parentc0c0526fc8076cff6e6dfd13b3e950898b405286 (diff)
downloadmpd-c6f101884b282a938c9c996ff613153520367b2a.tar.gz
mpd-c6f101884b282a938c9c996ff613153520367b2a.tar.xz
mpd-c6f101884b282a938c9c996ff613153520367b2a.zip
CrossFade: use negative value for invalid MixRamp overlap
Avoid NaN to allow -ffast-math.
Diffstat (limited to '')
-rw-r--r--src/CrossFade.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/CrossFade.cxx b/src/CrossFade.cxx
index 098987d19..8e6baf885 100644
--- a/src/CrossFade.cxx
+++ b/src/CrossFade.cxx
@@ -83,7 +83,7 @@ mixramp_interpolate(const char *ramp_list, float required_db)
return secs;
}
- return nan("");
+ return -1;
}
unsigned
@@ -96,7 +96,6 @@ CrossFadeSettings::Calculate(float total_time,
{
unsigned int chunks = 0;
float chunks_f;
- float mixramp_overlap;
if (duration < 0 || duration >= total_time ||
/* we can't crossfade when the audio formats are different */
@@ -112,9 +111,17 @@ CrossFadeSettings::Calculate(float total_time,
chunks = (chunks_f * duration + 0.5);
} else {
/* Calculate mixramp overlap. */
- mixramp_overlap = mixramp_interpolate(mixramp_start, mixramp_db - replay_gain_db)
- + mixramp_interpolate(mixramp_prev_end, mixramp_db - replay_gain_prev_db);
- if (!std::isnan(mixramp_overlap) &&
+ const float mixramp_overlap_current =
+ mixramp_interpolate(mixramp_start,
+ mixramp_db - replay_gain_db);
+ const float mixramp_overlap_prev =
+ mixramp_interpolate(mixramp_prev_end,
+ mixramp_db - replay_gain_prev_db);
+ const float mixramp_overlap =
+ mixramp_overlap_current + mixramp_overlap_prev;
+
+ if (mixramp_overlap_current >= 0 &&
+ mixramp_overlap_prev >= 0 &&
mixramp_delay <= mixramp_overlap) {
chunks = (chunks_f * (mixramp_overlap - mixramp_delay));
FormatDebug(cross_fade_domain,