CrossFade: eliminate NaN from mixramp_interpolate()

Use a boolean flag instead.
This commit is contained in:
Max Kellermann 2013-10-30 17:10:38 +01:00
parent c6f101884b
commit c4d3030d24
1 changed files with 4 additions and 4 deletions

View File

@ -25,8 +25,6 @@
#include "util/Domain.hxx"
#include "Log.hxx"
#include <cmath>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
@ -37,7 +35,8 @@ gcc_pure
static float
mixramp_interpolate(const char *ramp_list, float required_db)
{
float last_db = nan(""), last_secs = 0;
float last_db = 0, last_secs = 0;
bool have_last = false;
/* ramp_list is a string of pairs of dBs and seconds that describe the
* volume profile. Delimiters are semi-colons between pairs and spaces
@ -71,11 +70,12 @@ mixramp_interpolate(const char *ramp_list, float required_db)
if (db < required_db) {
last_db = db;
last_secs = secs;
have_last = true;
continue;
}
/* If required db < any stored value, use the least. */
if (std::isnan(last_db))
if (!have_last)
return secs;
/* Finally, interpolate linearly. */