mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-26 01:40:24 +00:00
Avoid division by zero in audio envelope processing. Fixes sound FX on android in some games.
This commit is contained in:
parent
ea2b923ddf
commit
a581e0d180
@ -646,9 +646,15 @@ static int durationFromRate(int rate)
|
||||
|
||||
const short expCurveReference = 0x7000;
|
||||
|
||||
// This needs a rewrite / rethink. Doing all this per sample is insane.
|
||||
static int getExpCurveAt(int index, int duration) {
|
||||
const short curveLength = sizeof(expCurve) / sizeof(short);
|
||||
|
||||
if (duration == 0) {
|
||||
// Avoid division by zero, and thus undefined behaviour in conversion to int.
|
||||
return 0;
|
||||
}
|
||||
|
||||
float curveIndex = (index * curveLength) / (float) duration;
|
||||
int curveIndex1 = (int) curveIndex;
|
||||
int curveIndex2 = curveIndex1 + 1;
|
||||
|
Loading…
Reference in New Issue
Block a user