Fix up gapless logic a little.
parent
876efcde38
commit
94259fd366
|
@ -360,27 +360,31 @@ audio_linear_round(unsigned int bits,
|
||||||
|
|
||||||
// NSLog(@"Counts: %i, %i", startingSample, sampleCount);
|
// NSLog(@"Counts: %i, %i", startingSample, sampleCount);
|
||||||
if (_foundLAMEHeader) {
|
if (_foundLAMEHeader) {
|
||||||
if (_framesDecoded < _startPadding) {
|
// We are at the beginning and need to skip frames
|
||||||
|
if (_startPadding > _framesDecoded) {
|
||||||
// NSLog(@"Skipping start.");
|
// NSLog(@"Skipping start.");
|
||||||
startingSample = _startPadding - _framesDecoded;
|
startingSample = _startPadding - _framesDecoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_framesDecoded > totalFrames - _endPadding + startingSample) {
|
// Past the end of the file.
|
||||||
|
if (totalFrames - _endPadding <= _framesDecoded) {
|
||||||
// NSLog(@"End of file. Not writing.");
|
// NSLog(@"End of file. Not writing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_framesDecoded + sampleCount + _endPadding > totalFrames + startingSample ) {
|
// We haven't even gotten to the start yet
|
||||||
// NSLog(@"End of file. %li", totalFrames - _endPadding - _framesDecoded);
|
|
||||||
sampleCount = totalFrames + startingSample - _endPadding - _framesDecoded;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (startingSample > sampleCount) {
|
if (startingSample > sampleCount) {
|
||||||
// NSLog(@"Skipping entire sample");
|
// NSLog(@"Skipping entire sample");
|
||||||
_framesDecoded += _synth.pcm.length;
|
_framesDecoded += _synth.pcm.length;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We are at the end of the file and need to read the last few frames
|
||||||
|
if (_framesDecoded + (sampleCount - startingSample) > totalFrames - _endPadding) {
|
||||||
|
// NSLog(@"End of file. %li", totalFrames - _endPadding - _framesDecoded);
|
||||||
|
sampleCount = totalFrames - _endPadding - _framesDecoded + startingSample;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//NSLog(@"Revised: %i, %i", startingSample, sampleCount);
|
//NSLog(@"Revised: %i, %i", startingSample, sampleCount);
|
||||||
|
|
Loading…
Reference in New Issue