Clamp the final sample count during decode.

Some games depend on / expect this, or else they'll let important data get
overwritten.
This commit is contained in:
Unknown W. Brackets 2014-09-22 23:21:08 -07:00
parent 68f4a1e7f7
commit fa42426d21

View File

@ -676,6 +676,9 @@ u32 _AtracDecodeData(int atracID, u8 *outbuf, u32 outbufPtr, u32 *SamplesNum, u3
skipSamples -= skipped;
numSamples = atrac->pFrame->nb_samples - skipped;
// If we're at the end, clamp to samples we want. It always returns a full chunk.
numSamples = std::min((u32)atrac->endSample - (u32)atrac->currentSample, numSamples);
if (skipped > 0 && numSamples == 0) {
// Wait for the next one.
got_frame = 0;