diff --git a/Core/HLE/AtracCtx.cpp b/Core/HLE/AtracCtx.cpp index 2ca9bbf952..14ee036062 100644 --- a/Core/HLE/AtracCtx.cpp +++ b/Core/HLE/AtracCtx.cpp @@ -946,10 +946,29 @@ int Atrac::DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, i return 0; } +void Atrac::CheckForSas() { + SetOutputChannels(1); +} + +int Atrac::EnqueueForSas(u32 bufPtr, u32 bytesToAdd) { + int addbytes = std::min(bytesToAdd, track_.fileSize - first_.fileoffset - track_.FirstOffsetExtra()); + Memory::Memcpy(dataBuf_ + first_.fileoffset + track_.FirstOffsetExtra(), bufPtr, addbytes, "AtracAddStreamData"); + first_.size += bytesToAdd; + if (first_.size >= track_.fileSize) { + first_.size = track_.fileSize; + if (bufferState_ == ATRAC_STATUS_HALFWAY_BUFFER) + bufferState_ = ATRAC_STATUS_ALL_DATA_LOADED; + } + first_.fileoffset += addbytes; + // refresh context_ + WriteContextToPSPMem(); + return 0; +} + void Atrac::DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) { - // Disabled, can't work now that we changed the interface. - *bytesWritten = 0; - *finish = 1; + // Hack, but works. + int samplesNum; + DecodeData((u8 *)dstData, 0, &samplesNum, finish, nullptr); } void Atrac::NotifyGetContextAddress() { diff --git a/Core/HLE/AtracCtx.h b/Core/HLE/AtracCtx.h index 94560ca111..276fd38a90 100644 --- a/Core/HLE/AtracCtx.h +++ b/Core/HLE/AtracCtx.h @@ -231,8 +231,8 @@ public: u32 DecodeData(u8 *outbuf, u32 outbufPtr, int *SamplesNum, int *finish, int *remains) override; int DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, int *bytesWritten) override; - void CheckForSas() {} - int EnqueueForSas(u32 address, u32 ptr) override { return 0; } + void CheckForSas() override; + int EnqueueForSas(u32 address, u32 ptr) override; void DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) override; // Returns how many samples the next DecodeData will write. diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 87a7af42e2..0a27836758 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -1138,7 +1138,6 @@ int AtracSasBindContextAndGetID(u32 contextAddr) { _dbg_assert_(atracID != -1); } - // Not actually a hack, this happens. AtracBase *atrac = getAtrac(atracID); atrac->CheckForSas(); return atracID;