Rearranged comparison to prevent underflow.

CQTexperiment
vspader 2009-02-26 21:31:20 -08:00
parent d8df7afcbb
commit 876efcde38
1 changed files with 9 additions and 9 deletions

View File

@ -370,14 +370,14 @@ audio_linear_round(unsigned int bits,
return;
}
if (_framesDecoded + (sampleCount - startingSample) > totalFrames - _endPadding) {
sampleCount = totalFrames - _endPadding - _framesDecoded + startingSample;
if (_framesDecoded + sampleCount + _endPadding > totalFrames + startingSample ) {
// NSLog(@"End of file. %li", totalFrames - _endPadding - _framesDecoded);
sampleCount = totalFrames + startingSample - _endPadding - _framesDecoded;
}
if (startingSample > sampleCount) {
_framesDecoded += _synth.pcm.length;
// NSLog(@"Skipping entire sample");
_framesDecoded += _synth.pcm.length;
return;
}