MAD Input: Further gapless decoding and seek fixes

This time, a two-fer. First, ensure that file start seeking still skips
over the Xing/LAME header packet properly. Then, ensure that decoding
the last desired packet of the file does not indicate having decoded
more sample data than desired, which may have caused errors when
resuming playback position on restart and then smoothly transitioning to
the next track.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-04-19 23:56:17 -07:00
parent 54f6702fb2
commit d1c6950ec6
1 changed files with 8 additions and 6 deletions

View File

@ -455,7 +455,7 @@
// DLog(@"Revised: %i, %i", startingSample, sampleCount); // DLog(@"Revised: %i, %i", startingSample, sampleCount);
_framesDecoded += _synth.pcm.length; _framesDecoded += sampleCount;
if(_outputFrames > 0) { if(_outputFrames > 0) {
DLog(@"LOSING FRAMES!"); DLog(@"LOSING FRAMES!");
@ -541,12 +541,14 @@
} }
} }
if(!_firstFrame || !_foundXingHeader) {
signed long frameDuration = mad_timer_count(_frame.header.duration, sampleRate); signed long frameDuration = mad_timer_count(_frame.header.duration, sampleRate);
if((framesToSkip - 1152 * 4) >= frameDuration) { if((framesToSkip - 1152 * 4) >= frameDuration) {
framesToSkip -= frameDuration; framesToSkip -= frameDuration;
_framesDecoded += frameDuration; _framesDecoded += frameDuration;
return 0; return 0;
} }
}
// DLog(@"Decoded buffer."); // DLog(@"Decoded buffer.");
mad_synth_frame(&_synth, &_frame); mad_synth_frame(&_synth, &_frame);