Mp3: Use a vector for the temp buffer.

Hopefully will move to reading RAM directly.  I think this was not always
adding data properly, as I got wrong output after decode.  Makes more
sense as a vector, anyway.
This commit is contained in:
Unknown W. Brackets 2019-04-28 11:56:39 -07:00
parent 122f871c74
commit fde59c955d
2 changed files with 10 additions and 4 deletions

View file

@ -351,7 +351,8 @@ u32 AuCtx::AuDecode(u32 pcmAddr) {
// get consumed source length
int srcPos = decoder->GetSourcePos() + nextSync;
// remove the consumed source
sourcebuff.erase(0, srcPos);
if (srcPos > 0)
sourcebuff.erase(sourcebuff.begin(), sourcebuff.begin() + srcPos);
// reduce the available Aubuff size
// (the available buff size is now used to know if we can read again from file and how many to read)
AuBufAvailable -= srcPos;
@ -430,7 +431,8 @@ u32 AuCtx::AuNotifyAddStreamData(int size) {
}
if (Memory::IsValidRange(AuBuf, size)) {
sourcebuff.append((const char *)Memory::GetPointer(AuBuf + offset), size);
sourcebuff.resize(sourcebuff.size() + size);
Memory::MemcpyUnchecked(&sourcebuff[sourcebuff.size() - size], AuBuf + offset, size);
}
return 0;

View file

@ -119,7 +119,11 @@ public:
void DoState(PointerWrap &p);
void EatSourceBuff(int amount) {
sourcebuff.erase(0, amount);
if (amount > sourcebuff.size()) {
amount = (int)sourcebuff.size();
}
if (amount > 0)
sourcebuff.erase(sourcebuff.begin(), sourcebuff.begin() + amount);
AuBufAvailable -= amount;
}
// Au source information. Written to from for example sceAacInit so public for now.
@ -155,7 +159,7 @@ public:
private:
size_t FindNextMp3Sync();
std::string sourcebuff; // source buffer
std::vector<u8> sourcebuff; // source buffer
};