From eb251af9647bbccca7acc2f8c15a87c3d67300ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 25 Mar 2025 00:30:31 +0100 Subject: [PATCH] Create decodeTemp_ on demand. Fixes #20150 --- Core/HLE/AtracCtx2.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Core/HLE/AtracCtx2.cpp b/Core/HLE/AtracCtx2.cpp index 035a3234d8..a3aeec8d36 100644 --- a/Core/HLE/AtracCtx2.cpp +++ b/Core/HLE/AtracCtx2.cpp @@ -697,6 +697,9 @@ u32 Atrac2::DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish) { _dbg_assert_(samplesToDecode <= info.SamplesPerFrame()); if (samplesToDecode != info.SamplesPerFrame()) { + if (!decodeTemp_) { + decodeTemp_ = new int16_t[info.SamplesPerFrame() * outputChannels_]; + } outPtr = decodeTemp_; } else { outPtr = outbufAddr ? (int16_t *)Memory::GetPointer(outbufAddr) : 0; // outbufAddr can be 0 during skip! @@ -846,12 +849,6 @@ int Atrac2::SetData(const Track &track, u32 bufferAddr, u32 readSize, u32 buffer info.loopEnd = 0; } - if (!decodeTemp_) { - _dbg_assert_(track.channels <= 2); - decodeTemp_ = new int16_t[track.SamplesPerFrame() * outputChannels + 1]; - decodeTemp_[track.SamplesPerFrame() * outputChannels] = 1337; // Sentinel - } - context_->codec.inBuf = bufferAddr; if (readSize > track.fileSize) {