From a2417b4779bdc0b30511506794910c56d81c9f68 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 16 Jan 2016 18:36:22 -0800 Subject: [PATCH] Atrac: Ensure correct fileoffset when adding data. If we looped, especially in the middle or toward the end, this ensures the data ends up in the correct place in our larger buffer. --- Core/HLE/sceAtrac.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 56ff0fc866..cd08a4217c 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -1046,12 +1046,14 @@ static u32 sceAtracAddStreamData(int atracID, u32 bytesToAdd) { return hleLogWarning(ME, ATRAC_ERROR_ALL_DATA_LOADED, "stream entirely loaded"); } - atrac->CalculateStreamInfo(nullptr); + u32 readOffset; + atrac->CalculateStreamInfo(&readOffset); if (bytesToAdd > atrac->first_.writableBytes) return hleLogWarning(ME, ATRAC_ERROR_ADD_DATA_IS_TOO_BIG, "too many bytes"); if (bytesToAdd > 0) { + atrac->first_.fileoffset = readOffset; int addbytes = std::min(bytesToAdd, atrac->first_.filesize - atrac->first_.fileoffset); if (!atrac->ignoreDataBuf_) { Memory::Memcpy(atrac->dataBuf_ + atrac->first_.fileoffset, atrac->first_.addr + atrac->first_.offset, addbytes);