Commit c6f10188 authored by Max Kellermann's avatar Max Kellermann

CrossFade: use negative value for invalid MixRamp overlap

Avoid NaN to allow -ffast-math.
parent c0c0526f
......@@ -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,
......
......@@ -43,7 +43,7 @@ public:
free(foo);
foo = strdup(input);
CPPUNIT_ASSERT(std::isnan(mixramp_interpolate(foo, 6.1)));
CPPUNIT_ASSERT(mixramp_interpolate(foo, 6.1) < 0);
free(foo);
foo = strdup(input);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment