Skip to content

Commit

Permalink
Atrac: Move buffer offset only if needed.
Browse files Browse the repository at this point in the history
Hmm, need to manage this buffer smarter, though, when streaming.  Right
now it's only getting it right enough to ask for the right amount of data,
really...

Fixes #8498.
  • Loading branch information
unknownbrackets committed Jan 24, 2016
1 parent 0550cd3 commit f1896ab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Core/HLE/sceAtrac.cpp
Expand Up @@ -1258,8 +1258,12 @@ u32 _AtracDecodeData(int atracID, u8 *outbuf, u32 outbufPtr, u32 *SamplesNum, u3
}
if ((atrac->bufferState_ & ATRAC_STATUS_STREAMED_MASK) == ATRAC_STATUS_STREAMED_MASK) {
// Whatever bytes we have left were added from the loop.
atrac->first_.fileoffset = atrac->FileOffsetBySample(atrac->loopStartSample_ - atrac->FirstOffsetExtra() - atrac->firstSampleOffset_ - atrac->SamplesPerFrame() * 2);
// Skip the initial frame at the start.
u32 loopOffset = atrac->FileOffsetBySample(atrac->loopStartSample_ - atrac->FirstOffsetExtra() - atrac->firstSampleOffset_ - atrac->SamplesPerFrame() * 2);
// TODO: Hmm, need to manage the buffer better. But don't move fileoffset if we already have valid data.
if (loopOffset > atrac->first_.fileoffset || loopOffset + atrac->bufferValidBytes_ < atrac->first_.fileoffset) {
// Skip the initial frame at the start.
atrac->first_.fileoffset = atrac->FileOffsetBySample(atrac->loopStartSample_ - atrac->FirstOffsetExtra() - atrac->firstSampleOffset_ - atrac->SamplesPerFrame() * 2);
}
}
} else if (hitEnd) {
finishFlag = 1;
Expand Down

0 comments on commit f1896ab

Please sign in to comment.