diff --git a/Core/HLE/AtracCtx.cpp b/Core/HLE/AtracCtx.cpp index 761117fa40..96e2156a01 100644 --- a/Core/HLE/AtracCtx.cpp +++ b/Core/HLE/AtracCtx.cpp @@ -234,6 +234,14 @@ void Track::DebugLog() { } int AnalyzeAtracTrack(u32 addr, u32 size, Track *track) { + // 72 is about the size of the minimum required data to even be valid. + + // TODO: Validate stuff more. + if (Memory::ReadUnchecked_U32(addr) != RIFF_CHUNK_MAGIC) { + ERROR_LOG(Log::ME, "Couldn't find RIFF header"); + return SCE_ERROR_ATRAC_UNKNOWN_FORMAT; + } + struct RIFFFmtChunk { u16_le fmtTag; u16_le channels; diff --git a/Core/HLE/AtracCtx.h b/Core/HLE/AtracCtx.h index e36e4c85bd..ae292b748f 100644 --- a/Core/HLE/AtracCtx.h +++ b/Core/HLE/AtracCtx.h @@ -356,6 +356,5 @@ private: u32 bufferValidBytes_ = 0; u32 bufferHeaderSize_ = 0; - // Refactor? int atracID_ = -1; }; diff --git a/Core/HLE/AtracCtx2.cpp b/Core/HLE/AtracCtx2.cpp index 8b4be5cb4a..3ed3e91a0b 100644 --- a/Core/HLE/AtracCtx2.cpp +++ b/Core/HLE/AtracCtx2.cpp @@ -9,31 +9,6 @@ // Windows\x64\debug\PPSSPPHeadless.exe --root pspautotests/tests/../ -o --compare --timeout=30 --graphics=software pspautotests/tests/audio/atrac/... --ignore pspautotests/tests/audio/atrac/second/resetting.prx --ignore pspautotests/tests/audio/atrac/second/replay.prx // // See the big comment in sceAtrac.cpp for an overview of the different modes of operation. -// -// Test cases -// -// Halfway buffer -// -// * None found yet -// -// All-data-loaded -// -// * MotoGP (menu music with specified loop). Simple repeated calls to sceAtracDecodeData -// * Archer MacLean's Mercury (in-game, not menu) -// * Crisis Core -// -// Streaming -// -// - Good ones (early) -// * Everybody's Golf 2 (0x2000 buffer size, loop from end) -// * Burnout Legends (no loop, 0x1800 buffer size) -// * Suicide Barbie -// - Others -// * Bleach -// * God of War: Chains of Olympus -// * Ape Academy 2 (bufsize 8192) -// * Half Minute Hero (bufsize 65536) -// * Flatout (tricky! needs investigation) Atrac2::Atrac2(int atracID, u32 contextAddr, int codecType) { @@ -85,7 +60,7 @@ int Atrac2::SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize } else { bufferState_ = ATRAC_STATUS_HALFWAY_BUFFER; } - return hleLogDebug(Log::ME, 0); + return 0; } u32 Atrac2::SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) { diff --git a/Core/HLE/AtracCtx2.h b/Core/HLE/AtracCtx2.h index 65a743650a..b2afd4614e 100644 --- a/Core/HLE/AtracCtx2.h +++ b/Core/HLE/AtracCtx2.h @@ -4,10 +4,10 @@ #include "Core/HLE/AtracCtx.h" - class Atrac2 : public AtracBase { public: Atrac2(int atracID, u32 contextAddr, int codecType); + void DoState(PointerWrap &p) override; int GetID() const override { return 0; } diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index 269b75bf2d..781dab1d60 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -227,13 +227,18 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking) { return ret; } + // NOTE: The below is WRONG! See issue #20095. + // + // What we should be queueing here is just the sampleAddress and sampleCount. Then when dequeuing is when we should + // read the actual data. + int leftVol = chan.leftVolume; int rightVol = chan.rightVolume; if (leftVol == (1 << 15) && rightVol == (1 << 15) && chan.format == PSP_AUDIO_FORMAT_STEREO && IS_LITTLE_ENDIAN) { // TODO: Add mono->stereo conversion to this path. - // Good news: the volume doesn't affect the values at all. + // Good news: the volume (1 << 15), specifically, doesn't affect the values at all. // We can just do a direct memory copy. const u32 totalSamples = chan.sampleCount * (chan.format == PSP_AUDIO_FORMAT_STEREO ? 2 : 1); s16 *buf1 = 0, *buf2 = 0; diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index d136338664..1fbe2fe617 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -129,6 +129,7 @@ void __AtracNotifyLoadModule(int version, u32 crc, u32 bssAddr, int bssSize) { g_atracBSS = bssAddr; g_atracMaxContexts = atracLibVersion <= 0x101 ? 4 : 6; // Need to figure out where the cutoff is. _dbg_assert_(bssSize >= g_atracMaxContexts * sizeof(SceAtracContext)); + NotifyMemInfo(MemBlockFlags::ALLOC, g_atracBSS, g_atracMaxContexts * sizeof(SceAtracContext), "AtracContext"); } void __AtracNotifyUnloadModule() { @@ -137,6 +138,7 @@ void __AtracNotifyUnloadModule() { INFO_LOG(Log::ME, "Atrac module unloaded."); g_atracBSS = 0; g_atracMaxContexts = 6; // TODO: We should make this zero here. + NotifyMemInfo(MemBlockFlags::FREE, g_atracBSS, g_atracMaxContexts * sizeof(SceAtracContext), "AtracContext"); } static u32 GetAtracContextAddress(int atracID) { diff --git a/Core/HLE/sceAtrac.h b/Core/HLE/sceAtrac.h index 5fff1a062e..316a1acb9c 100644 --- a/Core/HLE/sceAtrac.h +++ b/Core/HLE/sceAtrac.h @@ -79,7 +79,8 @@ struct SceAtracIdInfo { u32_le bufferByte; // 64 u32_le secondBufferByte; // 68 // make sure the size is 128 - u8 unk[56]; + u8 unk[52]; + u32_le atracID; }; struct SceAtracContext { diff --git a/headless/Headless.cpp b/headless/Headless.cpp index b818eebd86..863d84ffc0 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -330,7 +330,9 @@ int main(int argc, const char* argv[]) PROFILE_INIT(); TimeInit(); #if PPSSPP_PLATFORM(WINDOWS) - SetCleanExitOnAssert(); + if (!IsDebuggerPresent()) { + SetCleanExitOnAssert(); + } #else // Ignore sigpipe. if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {