From 84ccfde2ef35714d272aaf3dd086f2cf579b1e6a Mon Sep 17 00:00:00 2001 From: raven02 Date: Fri, 24 May 2013 23:20:14 +0800 Subject: [PATCH] Fix crash when low level decode hits atrac3 audio --- Core/HLE/sceAtrac.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 045e8d133..a90f4257c 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -1343,19 +1343,19 @@ int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesConsumedA WARN_LOG(HLE, "This is an atrac3+ stereo audio (low level)"); initAT3plusDecoder(atrac); } + int headersize = sizeof(at3plusHeader); + atrac->first.filesize = (*(u32*)(at3plusHeader + 4)) + 8; + atrac->data_buf = new u8[atrac->first.filesize]; + memcpy(atrac->data_buf, at3plusHeader, headersize); + int copysize = atrac->atracChannels == 2 ? sourcebytes : atrac->first.filesize - headersize; + memcpy(atrac->data_buf + headersize, Memory::GetPointer(sourceAddr), copysize); + atrac->firstSampleoffset = headersize; + atrac->first.size = headersize + atrac->atracBytesPerFrame; + atrac->first.fileoffset = atrac->first.size; + addAtrac3Audio(atrac->data_buf, atrac->atracChannels == 2 ? atrac->first.size : atrac->first.filesize, atracID); } else if (atrac->codeType == PSP_MODE_AT_3) { WARN_LOG(HLE, "This is an atrac3 audio (low level)"); } - int headersize = sizeof(at3plusHeader); - atrac->first.filesize = (*(u32*)(at3plusHeader + 4)) + 8; - atrac->data_buf = new u8[atrac->first.filesize]; - memcpy(atrac->data_buf, at3plusHeader, headersize); - int copysize = atrac->atracChannels == 2 ? sourcebytes : atrac->first.filesize - headersize; - memcpy(atrac->data_buf + headersize, Memory::GetPointer(sourceAddr), copysize); - atrac->firstSampleoffset = headersize; - atrac->first.size = headersize + atrac->atracBytesPerFrame; - atrac->first.fileoffset = atrac->first.size; - addAtrac3Audio(atrac->data_buf, atrac->atracChannels == 2 ? atrac->first.size : atrac->first.filesize, atracID); } else { audioEngine *engine = getaudioEngineByID(atracID);