diff --git a/Common/Log.h b/Common/Log.h index fdbc245e1ddd..f10bbbb18a9e 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -40,6 +40,8 @@ enum class Log { HLE, JIT, Loader, + Mpeg, + Atrac, ME, MemMap, SasMix, diff --git a/Common/Log/LogManager.cpp b/Common/Log/LogManager.cpp index 0e1ac799f488..b31ba0bad6dc 100644 --- a/Common/Log/LogManager.cpp +++ b/Common/Log/LogManager.cpp @@ -79,7 +79,9 @@ static const char * const g_logTypeNames[] = { "HLE", "JIT", "LOADER", - "ME", // Media Engine + "MPEG", + "ATRAC", + "ME", // Rest of the media Engine "MEMMAP", "SASMIX", "SAVESTATE", @@ -214,12 +216,12 @@ void LogManager::SaveConfig(Section *section) { } } -void LogManager::LoadConfig(const Section *section, bool debugDefaults) { +void LogManager::LoadConfig(const Section *section) { for (int i = 0; i < (int)Log::NUMBER_OF_LOGS; i++) { bool enabled = false; int level = 0; section->Get((std::string(g_logTypeNames[i]) + "Enabled"), &enabled, true); - section->Get((std::string(g_logTypeNames[i]) + "Level"), &level, (int)(debugDefaults ? LogLevel::LDEBUG : LogLevel::LERROR)); + section->Get((std::string(g_logTypeNames[i]) + "Level"), &level, (int)LogLevel::LERROR); g_log[i].enabled = enabled; g_log[i].level = (LogLevel)level; } diff --git a/Common/Log/LogManager.h b/Common/Log/LogManager.h index b522daf587a6..a366972866ec 100644 --- a/Common/Log/LogManager.h +++ b/Common/Log/LogManager.h @@ -153,7 +153,7 @@ class LogManager { const Path &GetLogFilePath() const { return logFilename_; } void SaveConfig(Section *section); - void LoadConfig(const Section *section, bool debugDefaults); + void LoadConfig(const Section *section); static const char *GetLogTypeName(Log type); diff --git a/Common/System/Request.cpp b/Common/System/Request.cpp index 532c28d4432c..739b61b6e000 100644 --- a/Common/System/Request.cpp +++ b/Common/System/Request.cpp @@ -72,7 +72,7 @@ bool RequestManager::MakeSystemRequest(SystemRequestType type, RequesterToken to callbackMap_[requestId] = { callback, failedCallback, token }; } - DEBUG_LOG(Log::System, "Making system request %s: id %d", RequestTypeAsString(type), requestId); + VERBOSE_LOG(Log::System, "Making system request %s: id %d", RequestTypeAsString(type), requestId); std::string p1(param1); std::string p2(param2); // TODO: Convert to string_view diff --git a/Core/Config.cpp b/Core/Config.cpp index c00a18b9b677..ad76481c46d2 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1217,11 +1217,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { Section *log = iniFile.GetOrCreateSection(logSectionName); - bool debugDefaults = false; -#ifdef _DEBUG - debugDefaults = true; -#endif - g_logManager.LoadConfig(log, debugDefaults); + g_logManager.LoadConfig(log); Section *recent = iniFile.GetOrCreateSection("Recent"); recent->Get("MaxRecent", &iMaxRecent, 60); diff --git a/Core/HLE/AtracCtx.cpp b/Core/HLE/AtracCtx.cpp index 9777085d3d89..30673e517d55 100644 --- a/Core/HLE/AtracCtx.cpp +++ b/Core/HLE/AtracCtx.cpp @@ -225,11 +225,11 @@ void Atrac::WriteContextToPSPMem() { } void Track::DebugLog() const { - DEBUG_LOG(Log::ME, "ATRAC analyzed: %s channels: %d filesize: %d bitrate: %d kbps jointStereo: %d", + DEBUG_LOG(Log::Atrac, "ATRAC analyzed: %s channels: %d filesize: %d bitrate: %d kbps jointStereo: %d", codecType == PSP_CODEC_AT3 ? "AT3" : "AT3Plus", channels, fileSize, bitrate / 1024, jointStereo); - DEBUG_LOG(Log::ME, "dataoff: %d firstSampleOffset: %d endSample: %d", dataByteOffset, firstSampleOffset, endSample); - DEBUG_LOG(Log::ME, "loopStartSample: %d loopEndSample: %d", loopStartSample, loopEndSample); - DEBUG_LOG(Log::ME, "sampleSize: %d (%03x", bytesPerFrame, bytesPerFrame); + DEBUG_LOG(Log::Atrac, "dataoff: %d firstSampleOffset: %d endSample: %d", dataByteOffset, firstSampleOffset, endSample); + DEBUG_LOG(Log::Atrac, "loopStartSample: %d loopEndSample: %d", loopStartSample, loopEndSample); + DEBUG_LOG(Log::Atrac, "sampleSize: %d (%03x)", bytesPerFrame, bytesPerFrame); } int Atrac::GetSoundSample(int *endSample, int *loopStartSample, int *loopEndSample) const { @@ -291,7 +291,7 @@ void Atrac::CalculateStreamInfo(u32 *outReadOffset) { // If you don't think this should be here, remove it. It's just a temporary safety check. if (first_.offset + first_.writableBytes > bufferMaxSize_) { - ERROR_LOG_REPORT(Log::ME, "Somehow calculated too many writable bytes: %d + %d > %d", first_.offset, first_.writableBytes, bufferMaxSize_); + ERROR_LOG_REPORT(Log::Atrac, "Somehow calculated too many writable bytes: %d + %d > %d", first_.offset, first_.writableBytes, bufferMaxSize_); first_.offset = 0; first_.writableBytes = bufferMaxSize_; } @@ -327,7 +327,7 @@ void AtracBase::CreateDecoder(int codecType, int bytesPerFrame, int channels) { } } -int Atrac::GetResetBufferInfo(AtracResetBufferInfo *bufferInfo, int sample, bool *delay) { +int Atrac::GetBufferInfoForResetting(AtracResetBufferInfo *bufferInfo, int sample, bool *delay) { *delay = false; if (BufferState() == ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER && !HasSecondBuffer()) { return SCE_ERROR_ATRAC_SECOND_BUFFER_NEEDED; @@ -417,7 +417,7 @@ int Atrac::SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize, first_._filesize_dontuse = track_.fileSize; if (outputChannels != track_.channels) { - WARN_LOG(Log::ME, "Atrac::SetData: outputChannels %d doesn't match track_.channels %d", outputChannels, track_.channels); + WARN_LOG(Log::Atrac, "Atrac::SetData: outputChannels %d doesn't match track_.channels %d", outputChannels, track_.channels); } first_.addr = buffer; @@ -438,7 +438,7 @@ int Atrac::SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize, if (track_.codecType != PSP_CODEC_AT3 && track_.codecType != PSP_CODEC_AT3PLUS) { // Shouldn't have gotten here, Analyze() checks this. bufferState_ = ATRAC_STATUS_NO_DATA; - ERROR_LOG(Log::ME, "unexpected codec type %d in set data", track_.codecType); + ERROR_LOG(Log::Atrac, "unexpected codec type %d in set data", track_.codecType); return SCE_ERROR_ATRAC_UNKNOWN_FORMAT; } @@ -467,10 +467,16 @@ int Atrac::SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize, Memory::Memcpy(dataBuf_, buffer, copybytes, "AtracSetData"); } CreateDecoder(track.codecType, track.bytesPerFrame, track.channels); - INFO_LOG(Log::ME, "Atrac::SetData (buffer=%08x, readSize=%d, bufferSize=%d): %s %s (%d channels) audio", buffer, readSize, bufferSize, codecName, channelName, track_.channels); + INFO_LOG(Log::Atrac, "Atrac::SetData (buffer=%08x, readSize=%d, bufferSize=%d): %s %s (%d channels) audio", buffer, readSize, bufferSize, codecName, channelName, track_.channels); + INFO_LOG(Log::Atrac, "BufferState: %s", AtracStatusToString(bufferState_)); + INFO_LOG(Log::Atrac, + "buffer: %08x bufferSize: %d readSize: %d bufferPos: %d\n", + buffer, bufferSize, readSize, bufferPos_ + ); if (track_.channels == 2 && outputChannels == 1) { // We still do all the tasks, we just return this error. + WARN_LOG(Log::Atrac, "Tried to load a stereo track into a mono context, returning NOT_MONO"); return SCE_ERROR_ATRAC_NOT_MONO; } return 0; @@ -494,7 +500,7 @@ int Atrac::SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) { return 0; } -int Atrac::GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) { +int Atrac::GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) const { if (BufferState() != ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER) { // Writes zeroes in this error case. *fileOffset = 0; @@ -715,7 +721,8 @@ u32 Atrac::DecodeData(u8 *outbuf, u32 outbufPtr, int *SamplesNum, int *finish, i // Skip the initial frame used to load state for the looped frame. // TODO: We will want to actually read this in. // TODO again: This seems to happen on the first frame of playback regardless of loops. - // Can't be good. + // Actually, this is explained now if we look at AtracCtx2, although this isn't really accurate. + DEBUG_LOG(Log::Atrac, "Calling ConsumeFrame to skip the initial frame"); ConsumeFrame(); } @@ -723,6 +730,9 @@ u32 Atrac::DecodeData(u8 *outbuf, u32 outbufPtr, int *SamplesNum, int *finish, i bool gotFrame = false; u32 off = track_.FileOffsetBySample(currentSample_ - skipSamples); + + DEBUG_LOG(Log::Atrac, "Decode(%08x): nextFileOff: %d", outbufPtr, off); + if (off < first_.size) { uint8_t *indata = BufferStart() + off; int bytesConsumed = 0; @@ -846,7 +856,7 @@ int Atrac::ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrit // Reuse the same calculation as before. AtracResetBufferInfo bufferInfo; bool ignored; - GetResetBufferInfo(&bufferInfo, sample, &ignored); + GetBufferInfoForResetting(&bufferInfo, sample, &ignored); if ((u32)bytesWrittenFirstBuf < bufferInfo.first.minWriteBytes || (u32)bytesWrittenFirstBuf > bufferInfo.first.writableBytes) { return SCE_ERROR_ATRAC_BAD_FIRST_RESET_SIZE; @@ -979,9 +989,9 @@ void Atrac::NotifyGetContextAddress() { context_ = kernelMemory.Alloc(contextSize, false, StringFromFormat("AtracCtx/%d", atracID_).c_str()); if (context_.IsValid()) Memory::Memset(context_.ptr, 0, contextSize, "AtracContextClear"); - WARN_LOG(Log::ME, "%08x=_sceAtracGetContextAddress(%i): allocated new context", context_.ptr, atracID_); + WARN_LOG(Log::Atrac, "%08x=_sceAtracGetContextAddress(%i): allocated new context", context_.ptr, atracID_); } else { - WARN_LOG(Log::ME, "%08x=_sceAtracGetContextAddress(%i)", context_.ptr, atracID_); + WARN_LOG(Log::Atrac, "%08x=_sceAtracGetContextAddress(%i)", context_.ptr, atracID_); } WriteContextToPSPMem(); } diff --git a/Core/HLE/AtracCtx.h b/Core/HLE/AtracCtx.h index 276fd38a90aa..75fa627af135 100644 --- a/Core/HLE/AtracCtx.h +++ b/Core/HLE/AtracCtx.h @@ -124,18 +124,18 @@ class AtracBase { virtual int BytesPerFrame() const = 0; virtual int SamplesPerFrame() const = 0; - virtual void GetStreamDataInfo(u32 *writePtr, u32 *writableBytes, u32 *readOffset) = 0; + virtual void GetStreamDataInfo(u32 *writePtr, u32 *writableBytes, u32 *readOffset) = 0; // This should be const, but the legacy impl stops it (it's wrong). virtual int AddStreamData(u32 bytesToAdd) = 0; virtual int ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf, bool *delay) = 0; - virtual int GetResetBufferInfo(AtracResetBufferInfo *bufferInfo, int sample, bool *delay) = 0; + virtual int GetBufferInfoForResetting(AtracResetBufferInfo *bufferInfo, int sample, bool *delay) = 0; // NOTE: Not const! This can cause SkipFrames! virtual int SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize, int outputChannels) = 0; - virtual int GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) = 0; + virtual int GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) const = 0; virtual int SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) = 0; virtual u32 DecodeData(u8 *outbuf, u32 outbufPtr, int *SamplesNum, int *finish, int *remains) = 0; virtual int DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, int *bytesWritten) = 0; - virtual u32 GetNextSamples() = 0; + virtual u32 GetNextSamples() = 0; // This should be const, but the legacy impl stops it (it's wrong). virtual void InitLowLevel(const Atrac3LowLevelParams ¶ms, int codecType) = 0; virtual void CheckForSas() = 0; @@ -224,9 +224,9 @@ class Atrac : public AtracBase { // Notify the player that the user has written some new data. int AddStreamData(u32 bytesToAdd) override; int ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf, bool *delay) override; - int GetResetBufferInfo(AtracResetBufferInfo *bufferInfo, int sample, bool *delay) override; + int GetBufferInfoForResetting(AtracResetBufferInfo *bufferInfo, int sample, bool *delay) override; // NOTE: Not const! This can cause SkipFrames! (although only in the AtracCtx2) int SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize, int outputChannels) override; - int GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) override; + int GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) const override; int SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) override; 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; diff --git a/Core/HLE/AtracCtx2.cpp b/Core/HLE/AtracCtx2.cpp index b758527c71eb..8fd967ac932b 100644 --- a/Core/HLE/AtracCtx2.cpp +++ b/Core/HLE/AtracCtx2.cpp @@ -10,6 +10,9 @@ #include "Core/System.h" #include "Core/HLE/AtracCtx2.h" #include "Core/HW/Atrac3Standalone.h" +#include "Core/Config.h" +#include "Core/MemMap.h" +#include "Common/File/FileUtil.h" // Convenient command line: // Windows\x64\debug\PPSSPPHeadless.exe --root pspautotests/tests/../ -o --compare --new-atrac --timeout=30 --graphics=software pspautotests/tests/audio/atrac/stream.prx @@ -183,6 +186,24 @@ Atrac2::Atrac2(u32 contextAddr, int codecType) { } } +Atrac2::~Atrac2() { + DumpBufferToFile(); + // Nothing else to do here, the context is freed by the HLE. +} + +void Atrac2::DumpBufferToFile() { + if (dumped_) { + // Already dumped, no need to dump again. + return; + } + if (!dumpBuffer_.empty()) { + std::string filename = StringFromFormat("atrac3_%08x_incomplete.at3", context_->info.endSample); + DumpFileIfEnabled(dumpBuffer_.data(), (u32)dumpBuffer_.size(), filename, DumpFileType::Atrac3); + dumpBuffer_.clear(); + } + dumped_ = true; +} + void Atrac2::DoState(PointerWrap &p) { auto s = p.Section("Atrac2", 1, 3); if (!s) @@ -331,7 +352,8 @@ u32 Atrac2::ResetPlayPositionInternal(int seekPos, int bytesWrittenFirstBuf, int } // This is basically sceAtracGetBufferInfoForResetting. -int Atrac2::GetResetBufferInfo(AtracResetBufferInfo *bufferInfo, int seekPos, bool *delay) { +// NOTE: Not const! This can cause SkipFrames! +int Atrac2::GetBufferInfoForResetting(AtracResetBufferInfo *bufferInfo, int seekPos, bool *delay) { const SceAtracIdInfo &info = context_->info; if (info.state == ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER && info.secondBufferByte == 0) { @@ -354,7 +376,7 @@ int Atrac2::GetResetBufferInfo(AtracResetBufferInfo *bufferInfo, int seekPos, bo return retval; } -void Atrac2::GetResetBufferInfoInternal(AtracResetBufferInfo *bufferInfo, int seekPos) { +void Atrac2::GetResetBufferInfoInternal(AtracResetBufferInfo *bufferInfo, int seekPos) const { const SceAtracIdInfo &info = context_->info; switch (info.state) { @@ -556,6 +578,12 @@ static void ComputeStreamBufferDataInfo(const SceAtracIdInfo &info, u32 *writePt const int loopStartFileOffset = ComputeFileOffset(info, info.loopStart); const int loopEndFileOffset = ComputeLoopEndFileOffset(info, info.loopEnd); + if (spaceLeftInBuffer < 0) { + // Most likely, the file was truncated. + WARN_LOG(Log::Atrac, "File corruption detected: spaceLeftInBuffer < 0: %d. Stumbling along.", spaceLeftInBuffer); + spaceLeftInBuffer = 0; + } + switch (info.state) { case ATRAC_STATUS_STREAMED_WITHOUT_LOOP: { @@ -666,6 +694,8 @@ u32 Atrac2::DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish) { return SCE_ERROR_ATRAC_ALL_DATA_DECODED; } + DEBUG_LOG(Log::Atrac, "Decode(%08x): samplesToDecode: %d nextFileOff: %d", outbufAddr, samplesToDecode, nextFileOff); + // Check for streaming buffer run-out. if (AtracStatusIsStreaming(info.state) && info.streamDataByte < info.sampleSize) { *finish = 0; @@ -710,7 +740,7 @@ u32 Atrac2::DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish) { context_->codec.outBuf = outbufAddr; if (!Memory::IsValidAddress(inAddr)) { - ERROR_LOG(Log::ME, "DecodeInternal: Bad inAddr %08x", inAddr); + ERROR_LOG(Log::Atrac, "DecodeInternal: Bad inAddr %08x", inAddr); return SCE_ERROR_ATRAC_API_FAIL; } @@ -821,19 +851,24 @@ int Atrac2::SetData(const Track &track, u32 bufferAddr, u32 readSize, u32 buffer if (track.codecType != PSP_CODEC_AT3 && track.codecType != PSP_CODEC_AT3PLUS) { // Shouldn't have gotten here, Analyze() checks this. - ERROR_LOG(Log::ME, "unexpected codec type %d in set data", track.codecType); + ERROR_LOG(Log::Atrac, "unexpected codec type %d in set data", track.codecType); return SCE_ERROR_ATRAC_UNKNOWN_FORMAT; } if (outputChannels != track.channels) { - INFO_LOG(Log::ME, "Atrac2::SetData: outputChannels %d doesn't match track_.channels %d, decoder will expand.", outputChannels, track.channels); + INFO_LOG(Log::Atrac, "Atrac2::SetData: outputChannels %d doesn't match track_.channels %d, decoder will expand.", outputChannels, track.channels); } if (readSize >= track.fileSize) { - INFO_LOG(Log::ME, "The full file was set directly - we can dump it."); + INFO_LOG(Log::Atrac, "The full file was set directly - we can dump it."); char filename[512]; snprintf(filename, sizeof(filename), "%s_%d%s", track.codecType == PSP_CODEC_AT3 ? "at3" : "at3plus", track.endSample, track.channels == 1 ? "_mono" : ""); DumpFileIfEnabled(Memory::GetPointer(bufferAddr), readSize, filename, DumpFileType::Atrac3); + } else if (false && (int)g_Config.iDumpFileTypes & (int)DumpFileType::Atrac3) { + // TODO: This is disabled (using the false above) until we can properly append streamed data to the dump. + // Still can be useful for debugging by dumping the start of the file, so leaving it here. + dumpBuffer_.resize(readSize); + Memory::Memcpy(dumpBuffer_.data(), bufferAddr, readSize); } CreateDecoder(track.codecType, track.bytesPerFrame, track.channels); @@ -853,7 +888,7 @@ int Atrac2::SetData(const Track &track, u32 bufferAddr, u32 readSize, u32 buffer context_->codec.inBuf = bufferAddr; if (readSize > track.fileSize) { - INFO_LOG(Log::ME, "readSize (%d) > track_.fileSize (%d)", readSize, track.fileSize); + INFO_LOG(Log::Atrac, "readSize (%d) > track_.fileSize (%d)", readSize, track.fileSize); } if (bufferSize >= track.fileSize) { @@ -875,7 +910,7 @@ int Atrac2::SetData(const Track &track, u32 bufferAddr, u32 readSize, u32 buffer } } - DEBUG_LOG(Log::ME, "Atrac mode setup: %s", AtracStatusToString(info.state)); + DEBUG_LOG(Log::Atrac, "Atrac mode setup: %s", AtracStatusToString(info.state)); // Copy parameters into state struct. info.codec = track.codecType; @@ -899,14 +934,25 @@ int Atrac2::SetData(const Track &track, u32 bufferAddr, u32 readSize, u32 buffer info.numSkipFrames = info.firstValidSample / info.SamplesPerFrame(); // NOTE: we do not write into secondBuffer/secondBufferByte! they linger... + INFO_LOG(Log::Atrac, + "Atrac: sampleSize: %d buffer: %08x bufferByte: %d firstValidSample: %d\n" + "endSample: %d loopStart: %d loopEnd: %d\n" + "dataOff: %d curFileOff: %d streamOff: %d streamDataByte: %d\n" + "fileDataEnd: %d decodePos: %d numSkipFrames: %d", + info.sampleSize, info.buffer, info.bufferByte, info.firstValidSample, + info.endSample, info.loopStart, info.loopEnd, + info.dataOff, info.curFileOff, info.streamOff, info.streamDataByte, + info.fileDataEnd, info.decodePos, info.numSkipFrames + ); + int skipCount = 0; // TODO: use for delay u32 retval = SkipFrames(&skipCount); // Seen in Mui Mui house. Things go very wrong after this.. if (retval == SCE_ERROR_ATRAC_API_FAIL) { - ERROR_LOG(Log::ME, "Bad frame during initial skip"); + ERROR_LOG(Log::Atrac, "Bad frame during initial skip"); } else if (retval != 0) { - ERROR_LOG(Log::ME, "SkipFrames during InitContext returned an error: %08x", retval); + ERROR_LOG(Log::Atrac, "SkipFrames during InitContext returned an error: %08x", retval); } WrapLastPacket(); return retval; @@ -921,7 +967,7 @@ void Atrac2::WrapLastPacket() { int distanceToEnd = RoundDownToMultiple(info.bufferByte - info.streamOff, info.sampleSize); if (info.streamDataByte < distanceToEnd) { // There's space left without wrapping. Don't do anything. - // INFO_LOG(Log::ME, "Packets fit into the buffer fully. %08x < %08x", readSize, bufferSize); + // INFO_LOG(Log::Atrac, "Packets fit into the buffer fully. %08x < %08x", readSize, bufferSize); // In this case, seems we need to zero some bytes. In one test, this seems to be 336. // Maybe there's a logical bug and the copy happens even when not needed, it's just that it'll // copy zeroes. Either way, let's just copy some bytes to make our sanity check hexdump pass. @@ -931,7 +977,7 @@ void Atrac2::WrapLastPacket() { const int copyStart = info.streamOff + distanceToEnd; const int copyLen = info.bufferByte - copyStart; // Then, let's copy it. - DEBUG_LOG(Log::ME, "Packets didn't fit evenly. Last packet got split into %d/%d (sum=%d). Copying to start of buffer.", + DEBUG_LOG(Log::Atrac, "Packets didn't fit evenly. Last packet got split into %d/%d (sum=%d). Copying to start of buffer.", copyLen, info.sampleSize - copyLen, info.sampleSize); Memory::Memcpy(info.buffer, info.buffer + copyStart, copyLen); } @@ -949,9 +995,12 @@ u32 Atrac2::SkipFrames(int *skipCount) { u32 retval = DecodeInternal(0, 0, &finishIgnored); if (retval != 0) { if (retval == SCE_ERROR_ATRAC_API_FAIL) { + WARN_LOG(Log::Atrac, "Failed during skip-frame, ignoring: %08x", retval); (*skipCount)++; } return retval; + } else { + DEBUG_LOG(Log::Atrac, "Frame correctly decoded during skip. numSkipFrames == %d", info.numSkipFrames); } (*skipCount)++; } @@ -959,7 +1008,7 @@ u32 Atrac2::SkipFrames(int *skipCount) { } // Where to read from to fill the second buffer. -int Atrac2::GetSecondBufferInfo(u32 *fileOffset, u32 *readSize) { +int Atrac2::GetSecondBufferInfo(u32 *fileOffset, u32 *readSize) const { const SceAtracIdInfo &info = context_->info; if (info.state != ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER) { // No second buffer needed in this state. @@ -1030,7 +1079,7 @@ int Atrac2::DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, int outSamples = 0; bool success = decoder_->Decode(srcData, info.sampleSize, bytesConsumed, channels, dstData, &outSamples); if (!success) { - ERROR_LOG(Log::ME, "Low level decoding failed: sampleSize: %d bytesConsumed: %d", info.sampleSize, *bytesConsumed); + ERROR_LOG(Log::Atrac, "Low level decoding failed: sampleSize: %d bytesConsumed: %d", info.sampleSize, *bytesConsumed); // We proceed anyway, see issue #20452 /* *bytesConsumed = 0; @@ -1046,16 +1095,16 @@ int Atrac2::DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData, void Atrac2::CheckForSas() { SceAtracIdInfo &info = context_->info; if (info.numChan != 1) { - WARN_LOG(Log::ME, "Caller forgot to set channels to 1"); + WARN_LOG(Log::Atrac, "Caller forgot to set channels to 1"); } if (info.state != 0x10) { - WARN_LOG(Log::ME, "Caller forgot to set state to 0x10"); + WARN_LOG(Log::Atrac, "Caller forgot to set state to 0x10"); } sas_.isStreaming = info.fileDataEnd > (s32)info.bufferByte; if (sas_.isStreaming) { - INFO_LOG(Log::ME, "SasAtrac stream mode"); + INFO_LOG(Log::Atrac, "SasAtrac stream mode"); } else { - INFO_LOG(Log::ME, "SasAtrac non-streaming mode"); + INFO_LOG(Log::Atrac, "SasAtrac non-streaming mode"); } } @@ -1068,10 +1117,10 @@ int Atrac2::EnqueueForSas(u32 address, u32 ptr) { } if (address == 0 && ptr == 0) { - WARN_LOG(Log::ME, "Caller tries to send us a zero buffer. Something went wrong."); + WARN_LOG(Log::Atrac, "Caller tries to send us a zero buffer. Something went wrong."); } - DEBUG_LOG(Log::ME, "EnqueueForSas: Second buffer updated to %08x, sz: %08x", address, ptr); + DEBUG_LOG(Log::Atrac, "EnqueueForSas: Second buffer updated to %08x, sz: %08x", address, ptr); info.secondBuffer = address; info.secondBufferByte = ptr; return 0; @@ -1101,12 +1150,12 @@ void Atrac2::DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) { int bytesConsumed = 0; bool decodeResult = decoder_->Decode(srcData, info.sampleSize, &bytesConsumed, 1, dstData, bytesWritten); if (!decodeResult) { - ERROR_LOG(Log::ME, "SAS failed to decode regular packet"); + ERROR_LOG(Log::Atrac, "SAS failed to decode regular packet"); } sas_.streamOffset += bytesConsumed; } else if (sas_.isStreaming) { // TODO: Do we need special handling for the first buffer, since SetData will wrap around that packet? I think yes! - DEBUG_LOG(Log::ME, "Streaming atrac through sas, and hit the end of buffer %d", sas_.curBuffer); + DEBUG_LOG(Log::Atrac, "Streaming atrac through sas, and hit the end of buffer %d", sas_.curBuffer); // Compute the part sizes using the current size. int part1Size = sas_.bufSize[sas_.curBuffer] - sas_.streamOffset; @@ -1119,7 +1168,7 @@ void Atrac2::DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) { // Check if we hit the end. if (sas_.fileOffset >= info.fileDataEnd) { - DEBUG_LOG(Log::ME, "Streaming and hit the file end."); + DEBUG_LOG(Log::Atrac, "Streaming and hit the file end."); *bytesWritten = 0; *finish = 1; return; @@ -1127,14 +1176,14 @@ void Atrac2::DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) { // Check that a new buffer actually exists if (info.secondBuffer == sas_.bufPtr[sas_.curBuffer]) { - ERROR_LOG(Log::ME, "Can't enqueue the same buffer twice in a row!"); + ERROR_LOG(Log::Atrac, "Can't enqueue the same buffer twice in a row!"); *bytesWritten = 0; *finish = 1; return; } if ((int)info.secondBuffer < 0) { - ERROR_LOG(Log::ME, "AtracSas streaming ran out of data, no secondbuffer pending"); + ERROR_LOG(Log::Atrac, "AtracSas streaming ran out of data, no secondbuffer pending"); *bytesWritten = 0; *finish = 1; return; @@ -1153,13 +1202,13 @@ void Atrac2::DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) { if (sas_.fileOffset >= info.fileDataEnd) { // We've reached the end. info.secondBuffer = 0; - DEBUG_LOG(Log::ME, "%08x >= %08x: Reached the end.", sas_.fileOffset, info.fileDataEnd); + DEBUG_LOG(Log::Atrac, "%08x >= %08x: Reached the end.", sas_.fileOffset, info.fileDataEnd); } else { // Signal to the caller that we accept a new next buffer. info.secondBuffer = 0xFFFFFFFF; } - DEBUG_LOG(Log::ME, "Switching over to buffer %d, updating buffer to %08x, sz: %08x. %s", sas_.curBuffer, info.secondBuffer, info.secondBufferByte, info.secondBuffer == 0xFFFFFFFF ? "Signalling for more data." : ""); + DEBUG_LOG(Log::Atrac, "Switching over to buffer %d, updating buffer to %08x, sz: %08x. %s", sas_.curBuffer, info.secondBuffer, info.secondBufferByte, info.secondBuffer == 0xFFFFFFFF ? "Signalling for more data." : ""); // Copy the second half (or if part1Size == 0, the whole packet) to the assembly buffer. Memory::Memcpy(assembly + part1Size, sas_.bufPtr[sas_.curBuffer], part2Size); @@ -1168,7 +1217,7 @@ void Atrac2::DecodeForSas(s16 *dstData, int *bytesWritten, int *finish) { int bytesConsumed = 0; bool decodeResult = decoder_->Decode(srcData, info.sampleSize, &bytesConsumed, 1, dstData, bytesWritten); if (!decodeResult) { - ERROR_LOG(Log::ME, "SAS failed to decode assembled packet"); + ERROR_LOG(Log::Atrac, "SAS failed to decode assembled packet"); } } } diff --git a/Core/HLE/AtracCtx2.h b/Core/HLE/AtracCtx2.h index 2a5554df667e..f1645a069938 100644 --- a/Core/HLE/AtracCtx2.h +++ b/Core/HLE/AtracCtx2.h @@ -8,9 +8,7 @@ class Atrac2 : public AtracBase { public: // The default values are only used during save state load, in which case they get restored by DoState. Atrac2(u32 contextAddr = 0, int codecType = 0); - ~Atrac2() { - delete[] decodeTemp_; - } + ~Atrac2(); AtracStatus BufferState() const override { return context_->info.state; @@ -31,10 +29,10 @@ class Atrac2 : public AtracBase { int CodecType() const override { return context_->info.codec; } void GetStreamDataInfo(u32 *writePtr, u32 *writableBytes, u32 *readOffset) override; - int GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) override; + int GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) const override; int AddStreamData(u32 bytesToAdd) override; int ResetPlayPosition(int sample, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf, bool *delay) override; - int GetResetBufferInfo(AtracResetBufferInfo *bufferInfo, int sample, bool *delay) override; + int GetBufferInfoForResetting(AtracResetBufferInfo *bufferInfo, int sample, bool *delay) override; int SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize, int outputChannels) override; int SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) override; bool HasSecondBuffer() const override; @@ -62,12 +60,14 @@ class Atrac2 : public AtracBase { private: u32 DecodeInternal(u32 outbufAddr, int *SamplesNum, int *finish); - void GetResetBufferInfoInternal(AtracResetBufferInfo *bufferInfo, int sample); + void GetResetBufferInfoInternal(AtracResetBufferInfo *bufferInfo, int sample) const; u32 ResetPlayPositionInternal(int seekPos, int bytesWrittenFirstBuf, int bytesWrittenSecondBuf); u32 SkipFrames(int *skippedCount); void WrapLastPacket(); + void DumpBufferToFile(); + // Just the current decoded frame, in order to be able to cut off the first part of it // to write the initial partial frame. // Does not need to be saved. @@ -76,4 +76,7 @@ class Atrac2 : public AtracBase { // This is hidden state inside sceSas, really. Not visible in the context. // But it doesn't really matter whether it's here or there. AtracSasStreamState sas_; + + std::vector dumpBuffer_; // Used for dumping audio data to files. + bool dumped_ = false; // Whether we already dumped the audio data to a file. }; diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index baa457cb70e7..1fafd0b61400 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -144,7 +144,7 @@ int __AtracMaxContexts() { void __AtracNotifyLoadModule(int version, u32 crc, u32 bssAddr, int bssSize) { atracLibVersion = version; atracLibCrc = crc; - INFO_LOG(Log::ME, "Atrac module loaded: atracLibVersion 0x%0x, atracLibcrc %x, bss: %x (%x bytes)", atracLibVersion, atracLibCrc, bssAddr, bssSize); + INFO_LOG(Log::Atrac, "Atrac module loaded: atracLibVersion 0x%0x, atracLibcrc %x, bss: %x (%x bytes)", atracLibVersion, atracLibCrc, bssAddr, 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)); @@ -155,7 +155,7 @@ void __AtracNotifyLoadModule(int version, u32 crc, u32 bssAddr, int bssSize) { void __AtracNotifyUnloadModule() { atracLibVersion = 0; atracLibCrc = 0; - INFO_LOG(Log::ME, "Atrac module unloaded."); + INFO_LOG(Log::Atrac, "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"); @@ -256,15 +256,15 @@ static int UnregisterAndDeleteAtrac(int atracID) { // Useful to initialize a context for low level decode. static u32 sceAtracGetAtracID(int codecType) { if (codecType != PSP_CODEC_AT3 && codecType != PSP_CODEC_AT3PLUS) { - return hleReportError(Log::ME, SCE_ERROR_ATRAC_INVALID_CODECTYPE, "invalid codecType"); + return hleReportError(Log::Atrac, SCE_ERROR_ATRAC_INVALID_CODECTYPE, "invalid codecType"); } int atracID = AllocAndRegisterAtrac(codecType); if (atracID < 0) { - return hleLogError(Log::ME, atracID, "no free ID"); + return hleLogError(Log::Atrac, atracID, "no free ID"); } - return hleLogInfo(Log::ME, atracID); + return hleLogInfo(Log::Atrac, atracID); } static int AtracValidateData(const AtracBase *atrac) { @@ -299,18 +299,18 @@ static u32 sceAtracAddStreamData(int atracID, u32 bytesToAdd) { AtracBase *atrac = getAtrac(atracID); int err = AtracValidateManaged(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (atrac->BufferState() == ATRAC_STATUS_ALL_DATA_LOADED) { // Let's avoid spurious warnings. Some games call this with 0 which is pretty harmless. if (bytesToAdd == 0) - return hleLogDebug(Log::ME, SCE_ERROR_ATRAC_ALL_DATA_LOADED, "stream entirely loaded"); - return hleLogWarning(Log::ME, SCE_ERROR_ATRAC_ALL_DATA_LOADED, "stream entirely loaded"); + return hleLogDebug(Log::Atrac, SCE_ERROR_ATRAC_ALL_DATA_LOADED, "stream entirely loaded"); + return hleLogWarning(Log::Atrac, SCE_ERROR_ATRAC_ALL_DATA_LOADED, "stream entirely loaded"); } int ret = atrac->AddStreamData(bytesToAdd); - return hleLogDebugOrError(Log::ME, ret); + return hleLogDebugOrError(Log::Atrac, ret); } // Note that outAddr being null is completely valid here, used to skip data. @@ -318,11 +318,11 @@ static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (outAddr & 1) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_BAD_ALIGNMENT); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_BAD_ALIGNMENT); } int numSamplesWritten = 0; @@ -330,7 +330,7 @@ static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 int remains = 0; if (outAddr != 0 && !Memory::IsValidAddress(outAddr)) { // Dunno what error code to return here, but we have to bail in this case to avoid crashing PPSSPP. - return hleLogError(Log::ME, SCE_ERROR_ATRAC_SIZE_TOO_SMALL); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_SIZE_TOO_SMALL); } u8 *outPtr = outAddr ? Memory::GetPointerWrite(outAddr) : nullptr; @@ -345,7 +345,7 @@ static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 if (ret == 0 && Memory::IsValidAddress(remainAddr)) Memory::WriteUnchecked_U32(remains, remainAddr); } - DEBUG_LOG(Log::ME, "%08x=sceAtracDecodeData(%i, %08x, %08x[%08x], %08x[%08x], %08x[%d])", ret, atracID, outAddr, + DEBUG_LOG(Log::Atrac, "%08x=sceAtracDecodeData(%i, %08x, %08x[%08x], %08x[%08x], %08x[%d])", ret, atracID, outAddr, numSamplesAddr, numSamplesWritten, finishFlagAddr, finish, remainAddr, remains); @@ -364,7 +364,7 @@ static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 static u32 sceAtracReleaseResources() { // In the real implementation, this just calls sceAudioCodecReleaseEDRAM if any has been allocated. - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } // Obtains information about what needs to be in the buffer to seek (or "reset") @@ -375,21 +375,21 @@ static u32 sceAtracGetBufferInfoForResetting(int atracID, int sample, u32 buffer AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (!bufferInfo.IsValid()) { - return hleLogError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid buffer, should crash"); + return hleLogError(Log::Atrac, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid buffer, should crash"); } // Note: If we error here, it's because of the internal SkipFrames. // We delayresult if we skip frames, which indeed can happen. bool delay = false; - int ret = atrac->GetResetBufferInfo(bufferInfo, sample, &delay); + int ret = atrac->GetBufferInfoForResetting(bufferInfo, sample, &delay); if (delay) { - return hleDelayResult(hleLogDebugOrError(Log::ME, ret), "getreset_frameskip", 300); + return hleDelayResult(hleLogDebugOrError(Log::Atrac, ret), "getreset_frameskip", 300); } else { - return hleLogDebugOrError(Log::ME, ret); + return hleLogDebugOrError(Log::Atrac, ret); } } @@ -397,15 +397,15 @@ static u32 sceAtracGetBitrate(int atracID, u32 outBitrateAddr) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } int bitrate = atrac->Bitrate(); if (Memory::IsValidAddress(outBitrateAddr)) { Memory::WriteUnchecked_U32(atrac->Bitrate(), outBitrateAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } else { - return hleLogError(Log::ME, 0, "invalid address"); + return hleLogError(Log::Atrac, 0, "invalid address"); } } @@ -413,14 +413,14 @@ static u32 sceAtracGetChannel(int atracID, u32 channelAddr) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (Memory::IsValidAddress(channelAddr)){ Memory::WriteUnchecked_U32(atrac->Channels(), channelAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } else { - return hleLogError(Log::ME, 0, "invalid address"); + return hleLogError(Log::Atrac, 0, "invalid address"); } } @@ -428,7 +428,7 @@ static u32 sceAtracGetLoopStatus(int atracID, u32 loopNumAddr, u32 statusAddr) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (Memory::IsValidAddress(loopNumAddr)) { @@ -438,9 +438,9 @@ static u32 sceAtracGetLoopStatus(int atracID, u32 loopNumAddr, u32 statusAddr) { if (Memory::IsValidAddress(statusAddr)) { const int loopStatus = atrac->LoopStatus(); Memory::WriteUnchecked_U32(loopStatus, statusAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } else { - return hleLogError(Log::ME, 0, "invalid address"); + return hleLogError(Log::Atrac, 0, "invalid address"); } } @@ -448,7 +448,7 @@ static u32 sceAtracGetInternalErrorInfo(int atracID, u32 errorAddr) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } const u32 errorCode = atrac->GetInternalCodecError(); @@ -457,9 +457,9 @@ static u32 sceAtracGetInternalErrorInfo(int atracID, u32 errorAddr) { } if (errorCode) { - return hleLogWarning(Log::ME, 0, "code: %08x", errorCode); + return hleLogWarning(Log::Atrac, 0, "code: %08x", errorCode); } else { - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } } @@ -467,14 +467,14 @@ static u32 sceAtracGetMaxSample(int atracID, u32 maxSamplesAddr) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (Memory::IsValidAddress(maxSamplesAddr)) { Memory::WriteUnchecked_U32(atrac->SamplesPerFrame(), maxSamplesAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } else { - return hleLogError(Log::ME, 0, "invalid address"); + return hleLogError(Log::Atrac, 0, "invalid address"); } } @@ -482,11 +482,11 @@ static u32 sceAtracGetNextDecodePosition(int atracID, u32 outposAddr) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (!Memory::IsValidAddress(outposAddr)) { - return hleLogError(Log::ME, 0, "invalid address"); + return hleLogError(Log::Atrac, 0, "invalid address"); } int pos = 0; @@ -494,28 +494,28 @@ static u32 sceAtracGetNextDecodePosition(int atracID, u32 outposAddr) { if (ret < 0) { if (ret == SCE_ERROR_ATRAC_ALL_DATA_DECODED) { // Benign. - return hleLogDebug(Log::ME, ret); + return hleLogDebug(Log::Atrac, ret); } else { - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } } Memory::WriteUnchecked_U32(pos, outposAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } static u32 sceAtracGetNextSample(int atracID, u32 outNAddr) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } int numSamples = atrac->GetNextSamples(); if (Memory::IsValidAddress(outNAddr)) { Memory::WriteUnchecked_U32(numSamples, outNAddr); } - return hleLogDebug(Log::ME, 0, "%d samples left", numSamples); + return hleLogDebug(Log::Atrac, 0, "%d samples left", numSamples); } // Obtains the number of frames remaining in the buffer which can be decoded. @@ -524,17 +524,17 @@ static u32 sceAtracGetRemainFrame(int atracID, u32 remainAddr) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (!Memory::IsValidAddress(remainAddr)) { // Would crash. - return hleReportError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid remainingFrames pointer"); + return hleReportError(Log::Atrac, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid remainingFrames pointer"); } u32 remaining = atrac->RemainingFrames(); Memory::WriteUnchecked_U32(remaining, remainAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } static u32 sceAtracGetSecondBufferInfo(int atracID, u32 fileOffsetAddr, u32 desiredSizeAddr) { @@ -544,20 +544,20 @@ static u32 sceAtracGetSecondBufferInfo(int atracID, u32 fileOffsetAddr, u32 desi AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (!fileOffset.IsValid() || !desiredSize.IsValid()) { // Would crash. - return hleReportError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid addresses"); + return hleReportError(Log::Atrac, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "invalid addresses"); } int result = atrac->GetSecondBufferInfo(fileOffset, desiredSize); switch (result) { case (int)SCE_ERROR_ATRAC_SECOND_BUFFER_NOT_NEEDED: - return hleLogDebug(Log::ME, result); + return hleLogDebug(Log::Atrac, result); default: - return hleLogDebugOrError(Log::ME, result); + return hleLogDebugOrError(Log::Atrac, result); } } @@ -565,7 +565,7 @@ static u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoop AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } int endSample = -1; @@ -573,7 +573,7 @@ static u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoop int loopEnd = -1; int retval = atrac->GetSoundSample(&endSample, &loopStart, &loopEnd); if (retval < 0) { - return hleLogError(Log::ME, retval); + return hleLogError(Log::Atrac, retval); } if (Memory::IsValidAddress(outEndSampleAddr)) { Memory::WriteUnchecked_U32(endSample, outEndSampleAddr); @@ -584,7 +584,7 @@ static u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoop if (Memory::IsValidAddress(outLoopEndSampleAddr)) { Memory::WriteUnchecked_U32(loopEnd, outLoopEndSampleAddr); } - return hleLogDebug(Log::ME, retval); + return hleLogDebug(Log::Atrac, retval); } // Games call this function to get some info for add more stream data, @@ -594,7 +594,7 @@ static u32 sceAtracGetStreamDataInfo(int atracID, u32 writePtrAddr, u32 writable AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } u32 writePtr; @@ -609,19 +609,19 @@ static u32 sceAtracGetStreamDataInfo(int atracID, u32 writePtrAddr, u32 writable if (Memory::IsValidAddress(readOffsetAddr)) Memory::WriteUnchecked_U32(readOffset, readOffsetAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } static u32 sceAtracReleaseAtracID(int atracID) { int result = UnregisterAndDeleteAtrac(atracID); if (result < 0) { if (atracID >= 0) { - return hleLogError(Log::ME, result, "did not exist"); + return hleLogError(Log::Atrac, result, "did not exist"); } else { - return hleLogWarning(Log::ME, result, "did not exist"); + return hleLogWarning(Log::Atrac, result, "did not exist"); } } - return hleLogDebug(Log::ME, result); + return hleLogDebug(Log::Atrac, result); } // This is called when a game wants to seek (or "reset") to a specific position in the audio data. @@ -631,16 +631,16 @@ static u32 sceAtracResetPlayPosition(int atracID, int sample, int bytesWrittenFi AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } bool delay = false; int res = atrac->ResetPlayPosition(sample, bytesWrittenFirstBuf, bytesWrittenSecondBuf, &delay); if (res < 0) { if (delay) { - return hleDelayResult(hleLogError(Log::ME, res), "reset play pos", 200); + return hleDelayResult(hleLogError(Log::Atrac, res), "reset play pos", 200); } else { - return hleLogError(Log::ME, res); + return hleLogError(Log::Atrac, res); } } @@ -651,74 +651,74 @@ static u32 sceAtracSetHalfwayBuffer(int atracID, u32 buffer, u32 readSize, u32 b AtracBase *atrac = getAtrac(atracID); // Don't use AtracValidateManaged here. if (!atrac) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_BAD_ATRACID, "invalid atrac ID"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_BAD_ATRACID, "invalid atrac ID"); } if (readSize > bufferSize) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); } Track track; std::string error; int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), readSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } if (track.codecType != atracContextTypes[atracID]) { // TODO: Should this not change the buffer size? - return hleLogError(Log::ME, SCE_ERROR_ATRAC_WRONG_CODECTYPE, "atracID uses different codec type than data"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_WRONG_CODECTYPE, "atracID uses different codec type than data"); } ret = atrac->SetData(track, buffer, readSize, bufferSize, 2); if (ret < 0) { // Must not delay. - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } // not sure the real delay time - return hleDelayResult(hleLogDebug(Log::ME, ret), "atrac set data", 100); + return hleDelayResult(hleLogDebug(Log::Atrac, ret), "atrac set data", 100); } static u32 sceAtracSetSecondBuffer(int atracID, u32 secondBuffer, u32 secondBufferSize) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } - return hleLogDebugOrError(Log::ME, atrac->SetSecondBuffer(secondBuffer, secondBufferSize)); + return hleLogDebugOrError(Log::Atrac, atrac->SetSecondBuffer(secondBuffer, secondBufferSize)); } static u32 sceAtracSetData(int atracID, u32 buffer, u32 bufferSize) { AtracBase *atrac = getAtrac(atracID); if (!atrac) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); } Track track; std::string error; int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), bufferSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } if (track.codecType != atracContextTypes[atracID]) { // TODO: Should this not change the buffer size? - return hleLogError(Log::ME, SCE_ERROR_ATRAC_WRONG_CODECTYPE, "atracID uses different codec type than data"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_WRONG_CODECTYPE, "atracID uses different codec type than data"); } ret = atrac->SetData(track, buffer, bufferSize, bufferSize, 2); if (ret < 0) { // Must not delay. - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } - return hleDelayResult(hleLogDebug(Log::ME, ret), "atrac set data", 100); + return hleDelayResult(hleLogDebug(Log::Atrac, ret), "atrac set data", 100); } static int sceAtracSetDataAndGetID(u32 buffer, int bufferSize) { // A large value happens in Tales of VS, and isn't handled somewhere properly as a u32. // It's impossible for it to be that big anyway, so cap it. if (bufferSize < 0) { - WARN_LOG(Log::ME, "sceAtracSetDataAndGetID(%08x, %08x): negative bufferSize", buffer, bufferSize); + WARN_LOG(Log::Atrac, "sceAtracSetDataAndGetID(%08x, %08x): negative bufferSize", buffer, bufferSize); bufferSize = 0x10000000; } @@ -728,51 +728,51 @@ static int sceAtracSetDataAndGetID(u32 buffer, int bufferSize) { // This is needed in Tomb Raider Legend (#20145). int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), bufferSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } int atracID = AllocAndRegisterAtrac(track.codecType); if (atracID < 0) { - return hleLogError(Log::ME, atracID, "no free ID"); + return hleLogError(Log::Atrac, atracID, "no free ID"); } ret = atracContexts[atracID]->SetData(track, buffer, bufferSize, bufferSize, 2); if (ret < 0) { UnregisterAndDeleteAtrac(atracID); - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } - return hleDelayResult(hleLogDebug(Log::ME, atracID), "atrac set data", 100); + return hleDelayResult(hleLogDebug(Log::Atrac, atracID), "atrac set data", 100); } static int sceAtracSetHalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 bufferSize) { if (readSize > bufferSize) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); } Track track; std::string error; int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), readSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } int atracID = AllocAndRegisterAtrac(track.codecType); if (atracID < 0) { - return hleLogError(Log::ME, atracID, "no free ID"); + return hleLogError(Log::Atrac, atracID, "no free ID"); } ret = atracContexts[atracID]->SetData(track, buffer, readSize, bufferSize, 2); if (ret < 0) { UnregisterAndDeleteAtrac(atracID); - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } - return hleDelayResult(hleLogDebug(Log::ME, atracID), "atrac set data", 100); + return hleDelayResult(hleLogDebug(Log::Atrac, atracID), "atrac set data", 100); } static u32 sceAtracStartEntry() { - ERROR_LOG_REPORT(Log::ME, "UNIMPL sceAtracStartEntry()"); + ERROR_LOG_REPORT(Log::Atrac, "UNIMPL sceAtracStartEntry()"); return 0; } @@ -780,21 +780,21 @@ static u32 sceAtracSetLoopNum(int atracID, int loopNum) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } int ret = atrac->SetLoopNum(loopNum); if (ret == SCE_ERROR_ATRAC_NO_LOOP_INFORMATION && (loopNum == -1 || loopNum == 0)) { // Not really an issue - return hleLogDebug(Log::ME, ret); + return hleLogDebug(Log::Atrac, ret); } - return hleLogDebugOrError(Log::ME, ret); + return hleLogDebugOrError(Log::Atrac, ret); } static int sceAtracReinit(int at3Count, int at3plusCount) { for (int i = 0; i < PSP_MAX_ATRAC_IDS; ++i) { if (atracContexts[i] != nullptr) { - return hleReportError(Log::ME, SCE_KERNEL_ERROR_BUSY, "cannot reinit while IDs in use"); + return hleReportError(Log::Atrac, SCE_KERNEL_ERROR_BUSY, "cannot reinit while IDs in use"); } } @@ -805,7 +805,7 @@ static int sceAtracReinit(int at3Count, int at3plusCount) { // This seems to deinit things. Mostly, it cause a reschedule on next deinit (but -1, -1 does not.) if (at3Count == 0 && at3plusCount == 0) { atracInited = false; - return hleDelayResult(hleLogInfo(Log::ME, 0, "deinit"), "atrac reinit", 200); + return hleDelayResult(hleLogInfo(Log::Atrac, 0, "deinit"), "atrac reinit", 200); } // First, ATRAC3+. These IDs seem to cost double (probably memory.) @@ -827,10 +827,10 @@ static int sceAtracReinit(int at3Count, int at3plusCount) { int result = space >= 0 ? 0 : (int)SCE_KERNEL_ERROR_OUT_OF_MEMORY; if (atracInited || next == 0) { atracInited = true; - return hleLogInfo(Log::ME, result); + return hleLogInfo(Log::Atrac, result); } else { atracInited = true; - return hleDelayResult(hleLogInfo(Log::ME, result), "atrac reinit", 400); + return hleDelayResult(hleLogInfo(Log::Atrac, result), "atrac reinit", 400); } } @@ -838,13 +838,13 @@ static int sceAtracGetOutputChannel(int atracID, u32 outputChanPtr) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateData(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } if (Memory::IsValidAddress(outputChanPtr)) { Memory::WriteUnchecked_U32(atrac->GetOutputChannels(), outputChanPtr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Atrac, 0); } else { - return hleLogError(Log::ME, 0, "invalid address"); + return hleLogError(Log::Atrac, 0, "invalid address"); } } @@ -852,37 +852,37 @@ static int sceAtracIsSecondBufferNeeded(int atracID) { AtracBase *atrac = getAtrac(atracID); u32 err = AtracValidateManaged(atrac); if (err != 0) { - return hleLogError(Log::ME, err); + return hleLogError(Log::Atrac, err); } // Note that this returns true whether the buffer is already set or not. int needed = atrac->BufferState() == ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER ? 1 : 0; - return hleLogDebug(Log::ME, needed); + return hleLogDebug(Log::Atrac, needed); } static int sceAtracSetMOutHalfwayBuffer(int atracID, u32 buffer, u32 readSize, u32 bufferSize) { AtracBase *atrac = getAtrac(atracID); // Don't use AtracValidate* here. if (!atrac) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); } if (readSize > bufferSize) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); } Track track; std::string error; int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), readSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } ret = atrac->SetData(track, buffer, readSize, bufferSize, 1); if (ret < 0 && ret != SCE_ERROR_ATRAC_NOT_MONO) { // Must not delay. - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } - return hleDelayResult(hleLogDebugOrError(Log::ME, ret), "atrac set data mono", 100); + return hleDelayResult(hleLogDebugOrError(Log::Atrac, ret), "atrac set data mono", 100); } // Note: This doesn't seem to be part of any available libatrac3plus library. @@ -892,23 +892,23 @@ static u32 sceAtracSetMOutData(int atracID, u32 buffer, u32 bufferSize) { AtracBase *atrac = getAtrac(atracID); // Don't use AtracValidate* here. if (!atrac) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); } Track track; std::string error; int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), bufferSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } ret = atrac->SetData(track, buffer, bufferSize, bufferSize, 1); if (ret < 0 && ret != SCE_ERROR_ATRAC_NOT_MONO) { // Must not delay. - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } // It's OK if this fails, at least with NO_MONO... - return hleDelayResult(hleLogDebugOrError(Log::ME, ret), "atrac set data mono", 100); + return hleDelayResult(hleLogDebugOrError(Log::Atrac, ret), "atrac set data mono", 100); } // Note: This doesn't seem to be part of any available libatrac3plus library. @@ -918,53 +918,53 @@ static int sceAtracSetMOutDataAndGetID(u32 buffer, u32 bufferSize) { std::string error; int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), bufferSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } if (track.channels != 1) { - return hleReportError(Log::ME, SCE_ERROR_ATRAC_NOT_MONO, "not mono data"); + return hleReportError(Log::Atrac, SCE_ERROR_ATRAC_NOT_MONO, "not mono data"); } int atracID = AllocAndRegisterAtrac(track.codecType); if (atracID < 0) { - return hleLogError(Log::ME, atracID, "no free ID"); + return hleLogError(Log::Atrac, atracID, "no free ID"); } ret = atracContexts[atracID]->SetData(track, buffer, bufferSize, bufferSize, 1); if (ret < 0 && ret != SCE_ERROR_ATRAC_NOT_MONO) { UnregisterAndDeleteAtrac(atracID); - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } - return hleDelayResult(hleLogDebugOrError(Log::ME, atracID), "atrac set data", 100); + return hleDelayResult(hleLogDebugOrError(Log::Atrac, atracID), "atrac set data", 100); } static int sceAtracSetMOutHalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 bufferSize) { if (readSize > bufferSize) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); } Track track; std::string error; int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), readSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } if (track.channels != 1) { - return hleReportError(Log::ME, SCE_ERROR_ATRAC_NOT_MONO, "not mono data"); + return hleReportError(Log::Atrac, SCE_ERROR_ATRAC_NOT_MONO, "not mono data"); } int atracID = AllocAndRegisterAtrac(track.codecType); if (atracID < 0) { - return hleLogError(Log::ME, atracID, "no free ID"); + return hleLogError(Log::Atrac, atracID, "no free ID"); } ret = atracContexts[atracID]->SetData(track, buffer, readSize, bufferSize, 1); if (ret < 0 && ret != SCE_ERROR_ATRAC_NOT_MONO) { UnregisterAndDeleteAtrac(atracID); - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } - return hleDelayResult(hleLogDebug(Log::ME, atracID), "atrac set data", 100); + return hleDelayResult(hleLogDebug(Log::Atrac, atracID), "atrac set data", 100); } static int sceAtracSetAA3DataAndGetID(u32 buffer, u32 bufferSize, u32 fileSize, u32 metadataSizeAddr) { @@ -972,47 +972,47 @@ static int sceAtracSetAA3DataAndGetID(u32 buffer, u32 bufferSize, u32 fileSize, std::string error; int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), bufferSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } int atracID = AllocAndRegisterAtrac(track.codecType); if (atracID < 0) { - return hleLogError(Log::ME, atracID, "no free ID"); + return hleLogError(Log::Atrac, atracID, "no free ID"); } ret = atracContexts[atracID]->SetData(track, buffer, bufferSize, bufferSize, 2); if (ret < 0) { UnregisterAndDeleteAtrac(atracID); - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } - return hleDelayResult(hleLogDebug(Log::ME, atracID), "atrac set aa3 data", 100); + return hleDelayResult(hleLogDebug(Log::Atrac, atracID), "atrac set aa3 data", 100); } static int sceAtracSetAA3HalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 bufferSize, u32 fileSize) { if (readSize > bufferSize) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_INCORRECT_READ_SIZE, "read size too large"); } Track track; std::string error; int ret = AnalyzeAtracTrack(Memory::GetPointerOrNull(buffer), readSize, &track, &error); if (ret < 0) { - return hleLogError(Log::ME, ret, "%s", error.c_str()); + return hleLogError(Log::Atrac, ret, "%s", error.c_str()); } int atracID = AllocAndRegisterAtrac(track.codecType); if (atracID < 0) { - return hleLogError(Log::ME, atracID, "no free ID"); + return hleLogError(Log::Atrac, atracID, "no free ID"); } ret = atracContexts[atracID]->SetData(track, buffer, readSize, bufferSize, 2); if (ret < 0) { UnregisterAndDeleteAtrac(atracID); - return hleLogError(Log::ME, ret); + return hleLogError(Log::Atrac, ret); } - return hleDelayResult(hleLogDebug(Log::ME, atracID), "atrac set data", 100); + return hleDelayResult(hleLogDebug(Log::Atrac, atracID), "atrac set data", 100); } // TODO: Should see if these are stored contiguously in memory somewhere, or if there really are @@ -1020,23 +1020,23 @@ static int sceAtracSetAA3HalfwayBufferAndGetID(u32 buffer, u32 readSize, u32 buf static u32 _sceAtracGetContextAddress(int atracID) { AtracBase *atrac = getAtrac(atracID); if (!atrac) { - return hleLogError(Log::ME, 0, "bad atrac id"); + return hleLogError(Log::Atrac, 0, "bad atrac id"); } // Only the old context needs this. The new one will always have a context pointer. atrac->NotifyGetContextAddress(); - return hleLogDebug(Log::ME, atrac->context_.ptr); + return hleLogDebug(Log::Atrac, atrac->context_.ptr); } static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) { AtracBase *atrac = getAtrac(atracID); if (!atrac) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); } if (!Memory::IsValidRange(paramsAddr, 12)) { // The real library will probably just crash here. - return hleReportError(Log::ME, 0, "invalid pointers"); + return hleReportError(Log::Atrac, 0, "invalid pointers"); } auto params = PSPPointer::Create(paramsAddr); @@ -1047,7 +1047,7 @@ static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) { const char *codecName = codecType == PSP_CODEC_AT3 ? "atrac3" : "atrac3+"; const char *encodedChannelName = params->encodedChannels == 1 ? "mono" : "stereo"; const char *outputChannelName = params->outputChannels == 1 ? "mono" : "stereo"; - return hleLogInfo(Log::ME, 0, "%s %s->%s audio", codecName, encodedChannelName, outputChannelName); + return hleLogInfo(Log::Atrac, 0, "%s %s->%s audio", codecName, encodedChannelName, outputChannelName); } static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesConsumedAddr, u32 samplesAddr, u32 sampleBytesAddr) { @@ -1058,12 +1058,12 @@ static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesCo AtracBase *atrac = getAtrac(atracID); if (!atrac) { - return hleLogError(Log::ME, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); + return hleLogError(Log::Atrac, SCE_ERROR_ATRAC_BAD_ATRACID, "bad atrac ID"); } if (!srcp.IsValid() || !srcConsumed.IsValid() || !outp.IsValid() || !outWritten.IsValid()) { // TODO: Returning zero as code was before. Needs testing. - return hleReportError(Log::ME, 0, "invalid pointers"); + return hleReportError(Log::Atrac, 0, "invalid pointers"); } int bytesConsumed = 0; @@ -1078,7 +1078,7 @@ static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesCo } NotifyMemInfo(MemBlockFlags::WRITE, samplesAddr, bytesWritten, "AtracLowLevelDecode"); - return hleDelayResult(hleLogDebug(Log::ME, retval), "low level atrac decode data", atracDecodeDelay); + return hleDelayResult(hleLogDebug(Log::Atrac, retval), "low level atrac decode data", atracDecodeDelay); } // These three are the external interface used by sceSas' AT3 integration. @@ -1092,7 +1092,7 @@ static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesCo u32 AtracSasAddStreamData(int atracID, u32 bufPtr, u32 bytesToAdd) { AtracBase *atrac = getAtrac(atracID); if (!atrac) { - WARN_LOG(Log::ME, "bad atrac ID"); + WARN_LOG(Log::Atrac, "bad atrac ID"); } return atrac->EnqueueForSas(bufPtr, bytesToAdd); } @@ -1100,7 +1100,7 @@ u32 AtracSasAddStreamData(int atracID, u32 bufPtr, u32 bytesToAdd) { void AtracSasDecodeData(int atracID, u8* outbuf, int *SamplesNum, int *finish) { AtracBase *atrac = getAtrac(atracID); if (!atrac) { - WARN_LOG(Log::ME, "bad atrac ID"); + WARN_LOG(Log::Atrac, "bad atrac ID"); } // NOTE: If streaming, this will write 0xFFFFFFFF to secondBuffer in the context when close to running // out of data. It'll then expect __sceSasConcatenateATRAC3 to concatenate a new buffer, which cannot diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 90040a66548e..20cf6fa97f0d 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -269,7 +269,7 @@ static void AnalyzeMpeg(const u8 *buffer, u32 validSize, MpegContext *ctx) { // Sanity Check ctx->mpegFirstTimestamp if (ctx->mpegFirstTimestamp != 90000) { - WARN_LOG_REPORT(Log::ME, "Unexpected mpeg first timestamp: %llx / %lld", ctx->mpegFirstTimestamp, ctx->mpegFirstTimestamp); + WARN_LOG_REPORT(Log::Mpeg, "Unexpected mpeg first timestamp: %llx / %lld", ctx->mpegFirstTimestamp, ctx->mpegFirstTimestamp); } if (ctx->mpegMagic != PSMF_MAGIC || ctx->mpegVersion < 0 || @@ -299,8 +299,8 @@ static void AnalyzeMpeg(const u8 *buffer, u32 validSize, MpegContext *ctx) { memcpy(ctx->mpegheader, buffer, validSize >= 2048 ? 2048 : validSize); *(u32_le*)(ctx->mpegheader + PSMF_STREAM_OFFSET_OFFSET) = 0x80000; - INFO_LOG(Log::ME, "Stream offset: %d, Stream size: 0x%X", ctx->mpegOffset, ctx->mpegStreamSize); - INFO_LOG(Log::ME, "First timestamp: %lld, Last timestamp: %lld", ctx->mpegFirstTimestamp, ctx->mpegLastTimestamp); + INFO_LOG(Log::Mpeg, "Stream offset: %d, Stream size: 0x%X", ctx->mpegOffset, ctx->mpegStreamSize); + INFO_LOG(Log::Mpeg, "First timestamp: %lld, Last timestamp: %lld", ctx->mpegFirstTimestamp, ctx->mpegLastTimestamp); } class PostPutAction : public PSPAction { @@ -388,11 +388,11 @@ void __MpegLoadModule(int version,u32 crc) { static u32 sceMpegInit() { if (isMpegInit) { - WARN_LOG(Log::ME, "sceMpegInit(): already initialized"); + WARN_LOG(Log::Mpeg, "sceMpegInit(): already initialized"); // TODO: Need to properly hook module load/unload for this to work right. //return SCE_MPEG_ERROR_ALREADY_INIT; } else { - INFO_LOG(Log::ME, "sceMpegInit(), mpegLibVersion 0x%0x, mpegLibcrc %x", mpegLibVersion, mpegLibCrc); + INFO_LOG(Log::Mpeg, "sceMpegInit(), mpegLibVersion 0x%0x, mpegLibcrc %x", mpegLibVersion, mpegLibCrc); } isMpegInit = true; return hleDelayResult(hleNoLog(0), "mpeg init", 750); @@ -404,27 +404,27 @@ static u32 __MpegRingbufferQueryMemSize(int packets) { static u32 sceMpegRingbufferQueryMemSize(int packets) { u32 size = __MpegRingbufferQueryMemSize(packets); - return hleLogDebug(Log::ME, size); + return hleLogDebug(Log::Mpeg, size); } static u32 sceMpegRingbufferConstruct(u32 ringbufferAddr, u32 numPackets, u32 data, u32 size, u32 callbackAddr, u32 callbackArg) { if (!Memory::IsValidAddress(ringbufferAddr)) { - ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): bad ringbuffer, should crash", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); + ERROR_LOG_REPORT(Log::Mpeg, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): bad ringbuffer, should crash", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); return hleNoLog(SCE_KERNEL_ERROR_ILLEGAL_ADDRESS); } if ((int)size < 0) { - ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): invalid size", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); + ERROR_LOG_REPORT(Log::Mpeg, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): invalid size", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); return hleNoLog(SCE_MPEG_ERROR_NO_MEMORY); } if (__MpegRingbufferQueryMemSize(numPackets) > size) { if (numPackets < 0x00100000) { - ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): too many packets for buffer", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); + ERROR_LOG_REPORT(Log::Mpeg, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): too many packets for buffer", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); return hleNoLog(SCE_MPEG_ERROR_NO_MEMORY); } else { // The PSP's firmware allows some cases here, due to a bug in its validation. - ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): too many packets for buffer, bogus size", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); + ERROR_LOG_REPORT(Log::Mpeg, "sceMpegRingbufferConstruct(%08x, %i, %08x, %08x, %08x, %08x): too many packets for buffer, bogus size", ringbufferAddr, numPackets, data, size, callbackAddr, callbackArg); } } @@ -442,13 +442,13 @@ static u32 sceMpegRingbufferConstruct(u32 ringbufferAddr, u32 numPackets, u32 da if (ring->semaID != 0) { // I'm starting to think this is just padding or something. // It's not written by this function. - WARN_LOG(Log::ME, "Detected semaID %d", ring->semaID); + WARN_LOG(Log::Mpeg, "Detected semaID %d", ring->semaID); } ring->mpeg = 0; // This isn't in ver 0104, but it is in 0105. if (mpegLibVersion >= 0x0105) ring->gp = __KernelGetModuleGP(__KernelGetCurThreadModuleId()); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static u32 MpegRequiredMem() { @@ -460,11 +460,11 @@ static u32 MpegRequiredMem() { static u32 sceMpegCreate(u32 mpegAddr, u32 dataPtr, u32 size, u32 ringbufferAddr, u32 frameWidth, u32 mode, u32 ddrTop) { if (!Memory::IsValidAddress(mpegAddr)) { - return hleLogWarning(Log::ME, -1, "invalid addresses"); + return hleLogWarning(Log::Mpeg, -1, "invalid addresses"); } if (size < MpegRequiredMem()) { - return hleLogWarning(Log::ME, SCE_MPEG_ERROR_NO_MEMORY); + return hleLogWarning(Log::Mpeg, SCE_MPEG_ERROR_NO_MEMORY); } auto ringbuffer = PSPPointer::Create(ringbufferAddr); @@ -520,41 +520,41 @@ static u32 sceMpegCreate(u32 mpegAddr, u32 dataPtr, u32 size, u32 ringbufferAddr ctx->isAnalyzed = false; ctx->mediaengine = new MediaEngine(); - return hleDelayResult(hleLogInfo(Log::ME, 0), "mpeg create", 29000); + return hleDelayResult(hleLogInfo(Log::Mpeg, 0), "mpeg create", 29000); } static int sceMpegDelete(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } delete ctx; g_mpegCtxs.erase(Memory::Read_U32(mpeg)); - return hleDelayResult(hleLogDebug(Log::ME, 0), "mpeg delete", 40000); + return hleDelayResult(hleLogDebug(Log::Mpeg, 0), "mpeg delete", 40000); } static int sceMpegAvcDecodeMode(u32 mpeg, u32 modeAddr) { if (!Memory::IsValidAddress(modeAddr)) { - return hleLogWarning(Log::ME, -1, "invalid addresses"); + return hleLogWarning(Log::Mpeg, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } - DEBUG_LOG(Log::ME, "sceMpegAvcDecodeMode(%08x, %08x)", mpeg, modeAddr); + DEBUG_LOG(Log::Mpeg, "sceMpegAvcDecodeMode(%08x, %08x)", mpeg, modeAddr); int mode = Memory::Read_U32(modeAddr); int pixelMode = Memory::Read_U32(modeAddr + 4); if (pixelMode >= GE_CMODE_16BIT_BGR5650 && pixelMode <= GE_CMODE_32BIT_ABGR8888) { ctx->videoPixelMode = pixelMode; } else { - ERROR_LOG(Log::ME, "sceMpegAvcDecodeMode(%i, %i): unknown pixelMode ", mode, pixelMode); + ERROR_LOG(Log::Mpeg, "sceMpegAvcDecodeMode(%i, %i): unknown pixelMode ", mode, pixelMode); } return hleNoLog(0); } @@ -562,12 +562,12 @@ static int sceMpegAvcDecodeMode(u32 mpeg, u32 modeAddr) static int sceMpegQueryStreamOffset(u32 mpeg, u32 bufferAddr, u32 offsetAddr) { if (!Memory::IsValidAddress(bufferAddr) || !Memory::IsValidAddress(offsetAddr)) { - return hleLogWarning(Log::ME, -1, "invalid addresses"); + return hleLogWarning(Log::Mpeg, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } // Kinda destructive, no? Shouldn't this just do what sceMpegQueryStreamSize does? @@ -575,23 +575,23 @@ static int sceMpegQueryStreamOffset(u32 mpeg, u32 bufferAddr, u32 offsetAddr) if (ctx->mpegMagic != PSMF_MAGIC) { Memory::WriteUnchecked_U32(0, offsetAddr); - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "Bad PSMF magic"); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE, "Bad PSMF magic"); } else if (ctx->mpegVersion < 0) { Memory::WriteUnchecked_U32(0, offsetAddr); - return hleLogError(Log::ME, SCE_MPEG_ERROR_BAD_VERSION, "Bad version"); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_BAD_VERSION, "Bad version"); } else if ((ctx->mpegOffset & 2047) != 0 || ctx->mpegOffset == 0) { Memory::WriteUnchecked_U32(0, offsetAddr); - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "Bad offset"); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE, "Bad offset"); } Memory::WriteUnchecked_U32(ctx->mpegOffset, offsetAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static u32 sceMpegQueryStreamSize(u32 bufferAddr, u32 sizeAddr) { if (!Memory::IsValidAddress(bufferAddr) || !Memory::IsValidAddress(sizeAddr)) { - return hleLogWarning(Log::ME, -1, "invalid addresses"); + return hleLogWarning(Log::Mpeg, -1, "invalid addresses"); } MpegContext ctx; @@ -602,21 +602,21 @@ static u32 sceMpegQueryStreamSize(u32 bufferAddr, u32 sizeAddr) if (ctx.mpegMagic != PSMF_MAGIC) { Memory::WriteUnchecked_U32(0, sizeAddr); - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "Bad PSMF magic"); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE, "Bad PSMF magic"); } else if ((ctx.mpegOffset & 2047) != 0 ) { Memory::WriteUnchecked_U32(0, sizeAddr); - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "Bad offset %08x", ctx.mpegOffset); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE, "Bad offset %08x", ctx.mpegOffset); } Memory::WriteUnchecked_U32(ctx.mpegStreamSize, sizeAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static int sceMpegRegistStream(u32 mpeg, u32 streamType, u32 streamNum) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } switch (streamType) { @@ -639,7 +639,7 @@ static int sceMpegRegistStream(u32 mpeg, u32 streamType, u32 streamNum) ctx->dataRegistered = true; break; default : - DEBUG_LOG(Log::ME, "sceMpegRegistStream(%i) : unknown stream type", streamType); + DEBUG_LOG(Log::Mpeg, "sceMpegRegistStream(%i) : unknown stream type", streamType); break; } // ... @@ -650,43 +650,43 @@ static int sceMpegRegistStream(u32 mpeg, u32 streamType, u32 streamNum) info.sid = sid; info.needsReset = true; ctx->streamMap[sid] = info; - return hleLogInfo(Log::ME, sid); + return hleLogInfo(Log::Mpeg, sid); } static int sceMpegMallocAvcEsBuf(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } // Doesn't actually malloc, just keeps track of a couple of flags for (int i = 0; i < MPEG_DATA_ES_BUFFERS; i++) { if (!ctx->esBuffers[i]) { ctx->esBuffers[i] = true; - return hleLogDebug(Log::ME, i + 1); + return hleLogDebug(Log::Mpeg, i + 1); } } // No es buffer - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static int sceMpegFreeAvcEsBuf(u32 mpeg, int esBuf) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } if (esBuf == 0) { - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE); } if (esBuf >= 1 && esBuf <= MPEG_DATA_ES_BUFFERS) { // TODO: Check if it's already been free'd? ctx->esBuffers[esBuf - 1] = false; } - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } // check the existence of pmp media context @@ -721,14 +721,14 @@ static bool InitPmp(MpegContext * ctx){ // Create H264 video codec AVCodec * pmp_Codec = avcodec_find_decoder(AV_CODEC_ID_H264); if (pmp_Codec == NULL){ - ERROR_LOG(Log::ME, "Can not find H264 codec, please update ffmpeg"); + ERROR_LOG(Log::Mpeg, "Can not find H264 codec, please update ffmpeg"); return false; } // Create CodecContext AVCodecContext * pmp_CodecCtx = avcodec_alloc_context3(pmp_Codec); if (pmp_CodecCtx == NULL){ - ERROR_LOG(Log::ME, "Can not allocate pmp Codec Context"); + ERROR_LOG(Log::Mpeg, "Can not allocate pmp Codec Context"); return false; } @@ -746,7 +746,7 @@ static bool InitPmp(MpegContext * ctx){ // Open pmp video codec if (avcodec_open2(pmp_CodecCtx, pmp_Codec, NULL) < 0){ - ERROR_LOG(Log::ME, "Can not open pmp video codec"); + ERROR_LOG(Log::Mpeg, "Can not open pmp video codec"); return false; } @@ -870,7 +870,7 @@ static bool decodePmpVideo(PSPPointer ringbuffer, u32 pmpctxA if (isContextExist(pmpctxAddr) == false){ bool ret = InitPmp(ctx); if (!ret){ - ERROR_LOG(Log::ME, "Pmp video initialization failed"); + ERROR_LOG(Log::Mpeg, "Pmp video initialization failed"); return false; } // add the initialized context into ContextList @@ -939,7 +939,7 @@ static bool decodePmpVideo(PSPPointer ringbuffer, u32 pmpctxA #else int len = avcodec_decode_video2(pCodecCtx, pFrame, &got_picture, &packet); #endif - DEBUG_LOG(Log::ME, "got_picture %d", got_picture); + DEBUG_LOG(Log::Mpeg, "got_picture %d", got_picture); if (got_picture){ SwsContext *img_convert_ctx = NULL; img_convert_ctx = sws_getContext( @@ -953,7 +953,7 @@ static bool decodePmpVideo(PSPPointer ringbuffer, u32 pmpctxA NULL, NULL, NULL); if (!img_convert_ctx) { - ERROR_LOG(Log::ME, "Cannot initialize sws conversion context"); + ERROR_LOG(Log::Mpeg, "Cannot initialize sws conversion context"); return false; } @@ -961,7 +961,7 @@ static bool decodePmpVideo(PSPPointer ringbuffer, u32 pmpctxA int swsRet = sws_scale(img_convert_ctx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameRGB->data, pFrameRGB->linesize); if (swsRet < 0){ - ERROR_LOG(Log::ME, "sws_scale: Error while converting %d", swsRet); + ERROR_LOG(Log::Mpeg, "sws_scale: Error while converting %d", swsRet); return false; } // free sws context @@ -1046,7 +1046,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } if (frameWidth == 0) { // wtf, go sudoku passes in 0xcccccccc @@ -1062,22 +1062,22 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr auto ringbuffer = PSPPointer::Create(ctx->mpegRingbufferAddr); if (!ringbuffer.IsValid()) { - return hleLogError(Log::ME, -1, "Bogus mpegringbufferaddr"); + return hleLogError(Log::Mpeg, -1, "Bogus mpegringbufferaddr"); } u32 buffer = Memory::Read_U32(bufferAddr); u32 init = Memory::Read_U32(initAddr); - DEBUG_LOG(Log::ME, "video: bufferAddr = %08x, *buffer = %08x, *init = %08x", bufferAddr, buffer, init); + DEBUG_LOG(Log::Mpeg, "video: bufferAddr = %08x, *buffer = %08x, *init = %08x", bufferAddr, buffer, init); // check and decode pmp video bool ispmp = false; if (decodePmpVideo(ringbuffer, mpeg)){ - DEBUG_LOG(Log::ME, "Using ffmpeg to decode pmp video"); + DEBUG_LOG(Log::Mpeg, "Using ffmpeg to decode pmp video"); ispmp = true; } if (ringbuffer->packetsRead == 0 || ctx->mediaengine->IsVideoEnd()) { - return hleDelayResult(hleLogWarning(Log::ME, SCE_MPEG_ERROR_AVC_DECODE_FATAL, "mpeg buffer empty"), "mpeg buffer empty", avcEmptyDelayMs); + return hleDelayResult(hleLogWarning(Log::Mpeg, SCE_MPEG_ERROR_AVC_DECODE_FATAL, "mpeg buffer empty"), "mpeg buffer empty", avcEmptyDelayMs); } s32 beforeAvail = ringbuffer->packets - ctx->mediaengine->getRemainSize() / 2048; @@ -1135,9 +1135,9 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr ctx->avc.avcDecodeResult = MPEG_AVC_DECODE_SUCCESS; if (ctx->videoFrameCount <= 1) { - return hleDelayResult(hleLogDebug(Log::ME, 0), "mpeg decode", accumDelay + avcFirstDelayMs); + return hleDelayResult(hleLogDebug(Log::Mpeg, 0), "mpeg decode", accumDelay + avcFirstDelayMs); } else { - return hleDelayResult(hleLogDebug(Log::ME, 0), "mpeg decode", accumDelay + avcDecodeDelayMs); + return hleDelayResult(hleLogDebug(Log::Mpeg, 0), "mpeg decode", accumDelay + avcDecodeDelayMs); } //hleEatMicro(3300); //return hleDelayResult(0, "mpeg decode", 200); @@ -1145,23 +1145,23 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr static u32 sceMpegAvcDecodeStop(u32 mpeg, u32 frameWidth, u32 bufferAddr, u32 statusAddr) { if (!Memory::IsValidAddress(bufferAddr) || !Memory::IsValidAddress(statusAddr)) { - return hleLogError(Log::ME, -1, "invalid addresses"); + return hleLogError(Log::Mpeg, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } // No last frame generated Memory::Write_U32(0, statusAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static u32 sceMpegUnRegistStream(u32 mpeg, int streamUid) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } StreamInfo info = {0}; @@ -1181,7 +1181,7 @@ static u32 sceMpegUnRegistStream(u32 mpeg, int streamUid) { ctx->dataRegistered = false; break; default : - DEBUG_LOG(Log::ME, "sceMpegUnRegistStream(%i) : unknown streamID ", streamUid); + DEBUG_LOG(Log::Mpeg, "sceMpegUnRegistStream(%i) : unknown streamID ", streamUid); break; } ctx->streamMap[streamUid] = info; @@ -1194,12 +1194,12 @@ static u32 sceMpegUnRegistStream(u32 mpeg, int streamUid) { static int sceMpegAvcDecodeDetail(u32 mpeg, u32 detailAddr) { if (!Memory::IsValidAddress(detailAddr)) { - return hleLogError(Log::ME, -1, "invalid addresses"); + return hleLogError(Log::Mpeg, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } Memory::Write_U32(ctx->avc.avcDecodeResult, detailAddr + 0); @@ -1211,20 +1211,20 @@ static int sceMpegAvcDecodeDetail(u32 mpeg, u32 detailAddr) { Memory::Write_U32(0, detailAddr + 24); Memory::Write_U32(0, detailAddr + 28); Memory::Write_U32(ctx->avc.avcFrameStatus, detailAddr + 32); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static u32 sceMpegAvcDecodeStopYCbCr(u32 mpeg, u32 bufferAddr, u32 statusAddr) { if (!Memory::IsValidAddress(bufferAddr) || !Memory::IsValidAddress(statusAddr)) { - return hleLogError(Log::ME, -1, "UNIMPL + invalid addresses"); + return hleLogError(Log::Mpeg, -1, "UNIMPL + invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL + bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL + bad mpeg handle"); } - ERROR_LOG(Log::ME, "UNIMPL sceMpegAvcDecodeStopYCbCr(%08x, %08x, %08x)", mpeg, bufferAddr, statusAddr); + ERROR_LOG(Log::Mpeg, "UNIMPL sceMpegAvcDecodeStopYCbCr(%08x, %08x, %08x)", mpeg, bufferAddr, statusAddr); Memory::Write_U32(0, statusAddr); return hleNoLog(0); } @@ -1233,7 +1233,7 @@ static int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initA { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } SceMpegAu avcAu; @@ -1241,11 +1241,11 @@ static int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initA auto ringbuffer = PSPPointer::Create(ctx->mpegRingbufferAddr); if (!ringbuffer.IsValid()) { - return hleLogError(Log::ME, -1, "Bogus mpegringbufferaddr"); + return hleLogError(Log::Mpeg, -1, "Bogus mpegringbufferaddr"); } if (ringbuffer->packetsRead == 0 || ctx->mediaengine->IsVideoEnd()) { - return hleDelayResult(hleLogWarning(Log::ME, SCE_MPEG_ERROR_AVC_DECODE_FATAL, "mpeg buffer empty"), "mpeg buffer empty", avcEmptyDelayMs); + return hleDelayResult(hleLogWarning(Log::Mpeg, SCE_MPEG_ERROR_AVC_DECODE_FATAL, "mpeg buffer empty"), "mpeg buffer empty", avcEmptyDelayMs); } s32 beforeAvail = ringbuffer->packets - ctx->mediaengine->getRemainSize() / 2048; @@ -1255,7 +1255,7 @@ static int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initA u32 buffer = Memory::Read_U32(bufferAddr); u32 init = Memory::Read_U32(initAddr); - DEBUG_LOG(Log::ME, "*buffer = %08x, *init = %08x", buffer, init); + DEBUG_LOG(Log::Mpeg, "*buffer = %08x, *init = %08x", buffer, init); if (ctx->mediaengine->stepVideo(ctx->videoPixelMode)) { // Don't draw here, we'll draw in the Csc func. @@ -1288,9 +1288,9 @@ static int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initA ctx->avc.avcDecodeResult = MPEG_AVC_DECODE_SUCCESS; if (ctx->videoFrameCount <= 1) - return hleDelayResult(hleLogDebug(Log::ME, 0), "mpeg decode", avcFirstDelayMs); + return hleDelayResult(hleLogDebug(Log::Mpeg, 0), "mpeg decode", avcFirstDelayMs); else - return hleDelayResult(hleLogDebug(Log::ME, 0), "mpeg decode", avcDecodeDelayMs); + return hleDelayResult(hleLogDebug(Log::Mpeg, 0), "mpeg decode", avcDecodeDelayMs); //hleEatMicro(3300); //return hleDelayResult(0, "mpeg decode", 200); @@ -1299,19 +1299,19 @@ static int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initA static u32 sceMpegAvcDecodeFlush(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL + bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL + bad mpeg handle"); } if ( ctx->videoFrameCount > 0 || ctx->audioFrameCount > 0) { //__MpegFinish(); } - return hleLogWarning(Log::ME, 0, "UNIMPL"); + return hleLogWarning(Log::Mpeg, 0, "UNIMPL"); } static int sceMpegInitAu(u32 mpeg, u32 bufferAddr, u32 auPointer) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } SceMpegAu sceAu; @@ -1338,33 +1338,33 @@ static int sceMpegInitAu(u32 mpeg, u32 bufferAddr, u32 auPointer) { sceAu.write(auPointer); } - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static int sceMpegQueryAtracEsSize(u32 mpeg, u32 esSizeAddr, u32 outSizeAddr) { if (!Memory::IsValidAddress(esSizeAddr) || !Memory::IsValidAddress(outSizeAddr)) { - return hleLogError(Log::ME, -1, "invalid addresses"); + return hleLogError(Log::Mpeg, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } Memory::Write_U32(MPEG_ATRAC_ES_SIZE, esSizeAddr); Memory::Write_U32(MPEG_ATRAC_ES_OUTPUT_SIZE, outSizeAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static int sceMpegRingbufferAvailableSize(u32 ringbufferAddr) { auto ringbuffer = PSPPointer::Create(ringbufferAddr); if (!ringbuffer.IsValid()) { - return hleLogError(Log::ME, SCE_KERNEL_ERROR_ILLEGAL_ADDRESS, "invalid ringbuffer, should crash"); + return hleLogError(Log::Mpeg, SCE_KERNEL_ERROR_ILLEGAL_ADDRESS, "invalid ringbuffer, should crash"); } MpegContext *ctx = getMpegCtx(ringbuffer->mpeg); if (!ctx) { - return hleLogError(Log::ME, SCE_MPEG_ERROR_NOT_YET_INIT, "bad mpeg handle"); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_NOT_YET_INIT, "bad mpeg handle"); } ctx->mpegRingbufferAddr = ringbufferAddr; @@ -1373,10 +1373,10 @@ static int sceMpegRingbufferAvailableSize(u32 ringbufferAddr) { static int lastAvail = 0; if (lastAvail != ringbuffer->packetsAvail) { - DEBUG_LOG(Log::ME, "%i=sceMpegRingbufferAvailableSize(%08x)", ringbuffer->packets - ringbuffer->packetsAvail, ringbufferAddr); + DEBUG_LOG(Log::Mpeg, "%i=sceMpegRingbufferAvailableSize(%08x)", ringbuffer->packets - ringbuffer->packetsAvail, ringbufferAddr); lastAvail = ringbuffer->packetsAvail; } else { - VERBOSE_LOG(Log::ME, "%i=sceMpegRingbufferAvailableSize(%08x)", ringbuffer->packets - ringbuffer->packetsAvail, ringbufferAddr); + VERBOSE_LOG(Log::Mpeg, "%i=sceMpegRingbufferAvailableSize(%08x)", ringbuffer->packets - ringbuffer->packetsAvail, ringbufferAddr); } return hleNoLog(ringbuffer->packets - ringbuffer->packetsAvail); } @@ -1411,7 +1411,7 @@ void PostPutAction::run(MipsCall &call) { if (invalid) { // Bail out early - don't accept any of the packets, even the good ones. // This happens during legit playback at the Burnout Legends menu! - ERROR_LOG(Log::ME, "sceMpegRingbufferPut(): invalid mpeg data"); + ERROR_LOG(Log::Mpeg, "sceMpegRingbufferPut(): invalid mpeg data"); call.setReturnValue(SCE_MPEG_ERROR_INVALID_VALUE); if (mpegLibVersion <= 0x0103) { @@ -1430,20 +1430,20 @@ void PostPutAction::run(MipsCall &call) { } if (packetsAddedThisRound > 0) { if (packetsAddedThisRound > ringbuffer->packets - ringbuffer->packetsAvail) { - WARN_LOG(Log::ME, "sceMpegRingbufferPut clamping packetsAdded old=%i new=%i", packetsAddedThisRound, ringbuffer->packets - ringbuffer->packetsAvail); + WARN_LOG(Log::Mpeg, "sceMpegRingbufferPut clamping packetsAdded old=%i new=%i", packetsAddedThisRound, ringbuffer->packets - ringbuffer->packetsAvail); packetsAddedThisRound = ringbuffer->packets - ringbuffer->packetsAvail; } const u8 *data = Memory::GetPointer(ringbuffer->data + writeOffset * 2048); uint32_t dataSize = Memory::ValidSize(ringbuffer->data + writeOffset * 2048, packetsAddedThisRound * 2048); int actuallyAdded = ctx->mediaengine == NULL ? 8 : ctx->mediaengine->addStreamData(data, dataSize) / 2048; if (actuallyAdded != packetsAddedThisRound) { - WARN_LOG_REPORT(Log::ME, "sceMpegRingbufferPut(): unable to enqueue all added packets, going to overwrite some frames."); + WARN_LOG_REPORT(Log::Mpeg, "sceMpegRingbufferPut(): unable to enqueue all added packets, going to overwrite some frames."); } ringbuffer->packetsRead += packetsAddedThisRound; ringbuffer->packetsWritePos += packetsAddedThisRound; ringbuffer->packetsAvail += packetsAddedThisRound; } - DEBUG_LOG(Log::ME, "packetAdded: %i packetsRead: %i packetsTotal: %i", packetsAddedThisRound, ringbuffer->packetsRead, ringbuffer->packets); + DEBUG_LOG(Log::Mpeg, "packetAdded: %i packetsRead: %i packetsTotal: %i", packetsAddedThisRound, ringbuffer->packetsRead, ringbuffer->packets); if (packetsAddedThisRound < 0 && ringbufferPutPacketsAdded == 0) { // Return an error. @@ -1460,7 +1460,7 @@ static u32 sceMpegRingbufferPut(u32 ringbufferAddr, int numPackets, int availabl auto ringbuffer = PSPPointer::Create(ringbufferAddr); if (!ringbuffer.IsValid()) { // Would have crashed before, TODO test behavior. - return hleLogError(Log::ME, -1, "invalid ringbuffer address"); + return hleLogError(Log::Mpeg, -1, "invalid ringbuffer address"); } numPackets = std::min(numPackets, available); @@ -1468,17 +1468,17 @@ static u32 sceMpegRingbufferPut(u32 ringbufferAddr, int numPackets, int availabl // Seems still need to check actual available, Patapon 3 for example. numPackets = std::min(numPackets, ringbuffer->packets - ringbuffer->packetsAvail); if (numPackets <= 0) { - return hleLogDebug(Log::ME, 0, "no packets to enqueue"); + return hleLogDebug(Log::Mpeg, 0, "no packets to enqueue"); } MpegContext *ctx = getMpegCtx(ringbuffer->mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle %08x", ringbuffer->mpeg); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle %08x", ringbuffer->mpeg); } ringbufferPutPacketsAdded = 0; // Execute callback function as a direct MipsCall, no blocking here so no messing around with wait states etc if (ringbuffer->callback_addr != 0) { - DEBUG_LOG(Log::ME, "sceMpegRingbufferPut(%08x, %i, %i)", ringbufferAddr, numPackets, available); + DEBUG_LOG(Log::Mpeg, "sceMpegRingbufferPut(%08x, %i, %i)", ringbufferAddr, numPackets, available); // Call this multiple times until we get numPackets. // Normally this would be if it did not read enough, but also if available > packets. @@ -1499,7 +1499,7 @@ static u32 sceMpegRingbufferPut(u32 ringbufferAddr, int numPackets, int availabl break; } } else { - ERROR_LOG_REPORT(Log::ME, "sceMpegRingbufferPut: callback_addr zero"); + ERROR_LOG_REPORT(Log::Mpeg, "sceMpegRingbufferPut: callback_addr zero"); } return hleNoLog(0); } @@ -1508,19 +1508,19 @@ static int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogError(Log::ME, -1, "bad mpeg handle"); + return hleLogError(Log::Mpeg, -1, "bad mpeg handle"); } auto ringbuffer = PSPPointer::Create(ctx->mpegRingbufferAddr); if (!ringbuffer.IsValid()) { // Would have crashed before, TODO test behavior. - return hleLogError(Log::ME, -1, "invalid ringbuffer address"); + return hleLogError(Log::Mpeg, -1, "invalid ringbuffer address"); } if (PSP_CoreParameter().compat.flags().MpegAvcWarmUp) { if (ctx->mpegwarmUp == 0) { ctx->mpegwarmUp++; - return hleLogDebug(Log::ME, SCE_MPEG_ERROR_NO_DATA, "warming up (%d)", ctx->mpegwarmUp); + return hleLogDebug(Log::Mpeg, SCE_MPEG_ERROR_NO_DATA, "warming up (%d)", ctx->mpegwarmUp); } } @@ -1532,12 +1532,12 @@ static int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) avcAu.dts = -1; avcAu.write(auAddr); // TODO: Does this really reschedule? - return hleDelayResult(hleLogDebug(Log::ME, SCE_MPEG_ERROR_NO_DATA), "mpeg get avc", mpegDecodeErrorDelayMs); + return hleDelayResult(hleLogDebug(Log::Mpeg, SCE_MPEG_ERROR_NO_DATA), "mpeg get avc", mpegDecodeErrorDelayMs); } auto streamInfo = ctx->streamMap.find(streamId); if (streamInfo == ctx->streamMap.end()) { - return hleLogWarning(Log::ME, -1, "invalid video stream %08x", streamId); + return hleLogWarning(Log::Mpeg, -1, "invalid video stream %08x", streamId); } if (streamInfo->second.needsReset) { @@ -1552,7 +1552,7 @@ static int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) /*// Wait for audio if too much ahead if (ctx->atracRegistered && (ctx->mediaengine->getVideoTimeStamp() > ctx->mediaengine->getAudioTimeStamp() + getMaxAheadTimestamp(mpegRingbuffer))) { - ERROR_LOG(Log::ME, "sceMpegGetAvcAu - video too much ahead"); + ERROR_LOG(Log::Mpeg, "sceMpegGetAvcAu - video too much ahead"); // TODO: Does this really reschedule? return hleDelayResult(SCE_MPEG_ERROR_NO_DATA, "mpeg get avc", mpegDecodeErrorDelayMs); }*/ @@ -1563,7 +1563,7 @@ static int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) avcAu.dts = avcAu.pts - videoTimestampStep; if (ctx->mediaengine->IsVideoEnd()) { - INFO_LOG(Log::ME, "video end reach. pts: %i dts: %i", (int)avcAu.pts, (int)ctx->mediaengine->getLastTimeStamp()); + INFO_LOG(Log::Mpeg, "video end reach. pts: %i dts: %i", (int)avcAu.pts, (int)ctx->mediaengine->getLastTimeStamp()); ringbuffer->packetsAvail = 0; result = SCE_MPEG_ERROR_NO_DATA; @@ -1579,39 +1579,39 @@ static int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) // TODO: sceMpegGetAvcAu seems to modify esSize, and delay when it's > 1000 or something. // There's definitely more to it, but ultimately it seems games should expect it to delay randomly. - return hleDelayResult(hleLogDebug(Log::ME, result), "mpeg get avc", 100); + return hleDelayResult(hleLogDebug(Log::Mpeg, result), "mpeg get avc", 100); } static u32 sceMpegFinish() { if (!isMpegInit) { - WARN_LOG(Log::ME, "sceMpegFinish(...): not initialized"); + WARN_LOG(Log::Mpeg, "sceMpegFinish(...): not initialized"); // TODO: Need to properly hook module load/unload for this to work right. //return SCE_MPEG_ERROR_NOT_YET_INIT; } else { - INFO_LOG(Log::ME, "sceMpegFinish()"); + INFO_LOG(Log::Mpeg, "sceMpegFinish()"); __VideoPmpShutdown(); } isMpegInit = false; //__MpegFinish(); - return hleDelayResult(hleLogDebug(Log::ME, 0), "mpeg finish", 250); + return hleDelayResult(hleLogDebug(Log::Mpeg, 0), "mpeg finish", 250); } static u32 sceMpegQueryMemSize() { - return hleLogDebug(Log::ME, MpegRequiredMem()); + return hleLogDebug(Log::Mpeg, MpegRequiredMem()); } static int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } auto ringbuffer = PSPPointer::Create(ctx->mpegRingbufferAddr); if (!ringbuffer.IsValid()) { // Would have crashed before, TODO test behavior. - return hleLogWarning(Log::ME, -1, "invalid ringbuffer address"); + return hleLogWarning(Log::Mpeg, -1, "invalid ringbuffer address"); } SceMpegAu atracAu; @@ -1623,14 +1623,14 @@ static int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) streamInfo->second.needsReset = false; } if (streamInfo == ctx->streamMap.end()) { - WARN_LOG_REPORT(Log::ME, "sceMpegGetAtracAu: invalid audio stream %08x", streamId); + WARN_LOG_REPORT(Log::Mpeg, "sceMpegGetAtracAu: invalid audio stream %08x", streamId); // TODO: Why was this changed to not return an error? } // The audio can end earlier than the video does. if (ringbuffer->packetsAvail == 0) { // TODO: Does this really delay? - return hleDelayResult(hleLogDebug(Log::ME, SCE_MPEG_ERROR_NO_DATA), "mpeg get atrac", mpegDecodeErrorDelayMs); + return hleDelayResult(hleLogDebug(Log::Mpeg, SCE_MPEG_ERROR_NO_DATA), "mpeg get atrac", mpegDecodeErrorDelayMs); } // esBuffer is the memory where this au data goes. We don't write the data to memory. @@ -1644,17 +1644,17 @@ static int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) atracAu.pts = ctx->mediaengine->getAudioTimeStamp() + ctx->mpegFirstTimestamp; if (ctx->mediaengine->IsVideoEnd()) { - INFO_LOG(Log::ME, "video end reach. pts: %i dts: %i", (int)atracAu.pts, (int)ctx->mediaengine->getLastTimeStamp()); + INFO_LOG(Log::Mpeg, "video end reach. pts: %i dts: %i", (int)atracAu.pts, (int)ctx->mediaengine->getLastTimeStamp()); ringbuffer->packetsAvail = 0; // TODO: Is this correct? if (!ctx->mediaengine->IsNoAudioData()) { - WARN_LOG_REPORT(Log::ME, "Video end without audio end, potentially skipping some audio?"); + WARN_LOG_REPORT(Log::Mpeg, "Video end without audio end, potentially skipping some audio?"); } result = SCE_MPEG_ERROR_NO_DATA; } if (ctx->atracRegistered && ctx->mediaengine->IsNoAudioData() && !ctx->endOfAudioReached) { - WARN_LOG(Log::ME, "Audio end reach. pts: %i dts: %i", (int)atracAu.pts, (int)ctx->mediaengine->getLastTimeStamp()); + WARN_LOG(Log::Mpeg, "Audio end reach. pts: %i dts: %i", (int)atracAu.pts, (int)ctx->mediaengine->getLastTimeStamp()); ctx->endOfAudioReached = true; } if (ctx->mediaengine->IsNoAudioData()) { @@ -1669,23 +1669,23 @@ static int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr) } // TODO: Not clear on exactly when this delays. - return hleDelayResult(hleLogDebug(Log::ME, result), "mpeg get atrac", 100); + return hleDelayResult(hleLogDebug(Log::Mpeg, result), "mpeg get atrac", 100); } static int sceMpegQueryPcmEsSize(u32 mpeg, u32 esSizeAddr, u32 outSizeAddr) { if (!Memory::IsValidAddress(esSizeAddr) || !Memory::IsValidAddress(outSizeAddr)) { - return hleLogError(Log::ME, -1, "invalid addresses"); + return hleLogError(Log::Mpeg, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } Memory::Write_U32(MPEG_PCM_ES_SIZE, esSizeAddr); Memory::Write_U32(MPEG_PCM_ES_OUTPUT_SIZE, outSizeAddr); - return hleLogError(Log::ME, 0, "UNIMPL"); + return hleLogError(Log::Mpeg, 0, "UNIMPL"); } @@ -1693,18 +1693,18 @@ static u32 sceMpegChangeGetAuMode(u32 mpeg, int streamUid, int mode) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "bad mpeg handle"); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE, "bad mpeg handle"); } if (mode != MPEG_AU_MODE_DECODE && mode != MPEG_AU_MODE_SKIP) { - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "UNIMPL / bad mode"); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE, "UNIMPL / bad mode"); } auto stream = ctx->streamMap.find(streamUid); if (stream == ctx->streamMap.end()) { - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "UNIMPL / unknown streamID"); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE, "UNIMPL / unknown streamID"); } else { StreamInfo &info = stream->second; - DEBUG_LOG(Log::ME, "UNIMPL sceMpegChangeGetAuMode(%08x, %i, %i): changing type=%d", mpeg, streamUid, mode, info.type); + DEBUG_LOG(Log::Mpeg, "UNIMPL sceMpegChangeGetAuMode(%08x, %i, %i): changing type=%d", mpeg, streamUid, mode, info.type); switch (info.type) { case MPEG_AVC_STREAM: if (mode == MPEG_AU_MODE_DECODE) { @@ -1729,7 +1729,7 @@ static u32 sceMpegChangeGetAuMode(u32 mpeg, int streamUid, int mode) } break; default: - ERROR_LOG(Log::ME, "UNIMPL sceMpegChangeGetAuMode(%08x, %i, %i): unknown streamID", mpeg, streamUid, mode); + ERROR_LOG(Log::Mpeg, "UNIMPL sceMpegChangeGetAuMode(%08x, %i, %i): unknown streamID", mpeg, streamUid, mode); break; } } @@ -1738,15 +1738,15 @@ static u32 sceMpegChangeGetAuMode(u32 mpeg, int streamUid, int mode) static u32 sceMpegChangeGetAvcAuMode(u32 mpeg, u32 stream_addr, int mode) { if (!Memory::IsValidAddress(stream_addr)) { - return hleLogError(Log::ME, -1, "invalid addresses"); + return hleLogError(Log::Mpeg, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL + bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL + bad mpeg handle"); } - ERROR_LOG_REPORT_ONCE(mpegChangeAvcAu, Log::ME, "UNIMPL sceMpegChangeGetAvcAuMode(%08x, %08x, %i)", mpeg, stream_addr, mode); + ERROR_LOG_REPORT_ONCE(mpegChangeAvcAu, Log::Mpeg, "UNIMPL sceMpegChangeGetAvcAuMode(%08x, %08x, %i)", mpeg, stream_addr, mode); return 0; } @@ -1754,22 +1754,22 @@ static u32 sceMpegGetPcmAu(u32 mpeg, int streamUid, u32 auAddr, u32 attrAddr) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } auto ringbuffer = PSPPointer::Create(ctx->mpegRingbufferAddr); if (!ringbuffer.IsValid()) { // Would have crashed before, TODO test behavior - return hleLogWarning(Log::ME, -1, "invalid ringbuffer address"); + return hleLogWarning(Log::Mpeg, -1, "invalid ringbuffer address"); } if (!Memory::IsValidAddress(streamUid)) { - return hleLogWarning(Log::ME, SCE_MPEG_ERROR_INVALID_ADDR, "didn't get a fake stream, bad streamUid address"); + return hleLogWarning(Log::Mpeg, SCE_MPEG_ERROR_INVALID_ADDR, "didn't get a fake stream, bad streamUid address"); } SceMpegAu atracAu; atracAu.read(auAddr); auto streamInfo = ctx->streamMap.find(streamUid); if (streamInfo == ctx->streamMap.end()) { - return hleLogWarning(Log::ME, -1, "bad streamUid "); + return hleLogWarning(Log::Mpeg, -1, "bad streamUid "); } atracAu.write(auAddr); @@ -1778,7 +1778,7 @@ static u32 sceMpegGetPcmAu(u32 mpeg, int streamUid, u32 auAddr, u32 attrAddr) if (Memory::IsValidAddress(attrAddr)) Memory::WriteUnchecked_U32(attr, attrAddr); - ERROR_LOG_REPORT_ONCE(mpegPcmAu, Log::ME, "UNIMPL sceMpegGetPcmAu(%08x, %i, %08x, %08x)", mpeg, streamUid, auAddr, attrAddr); + ERROR_LOG_REPORT_ONCE(mpegPcmAu, Log::Mpeg, "UNIMPL sceMpegGetPcmAu(%08x, %i, %08x, %08x)", mpeg, streamUid, auAddr, attrAddr); return hleNoLog(0); } @@ -1787,14 +1787,14 @@ static int __MpegRingbufferQueryPackNum(u32 memorySize) { } static int sceMpegRingbufferQueryPackNum(u32 memorySize) { - DEBUG_LOG(Log::ME, "sceMpegRingbufferQueryPackNum(%i)", memorySize); + DEBUG_LOG(Log::Mpeg, "sceMpegRingbufferQueryPackNum(%i)", memorySize); return __MpegRingbufferQueryPackNum(memorySize); } static u32 sceMpegFlushAllStream(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL + bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL + bad mpeg handle"); } ctx->isAnalyzed = false; @@ -1806,47 +1806,47 @@ static u32 sceMpegFlushAllStream(u32 mpeg) { ringbuffer->packetsWritePos = 0; } - return hleLogWarning(Log::ME, 0, "UNIMPL"); + return hleLogWarning(Log::Mpeg, 0, "UNIMPL"); } static u32 sceMpegFlushStream(u32 mpeg, int stream_addr) { if (!Memory::IsValidAddress(stream_addr)) { - return hleLogError(Log::ME, -1, "UNIMPL / invalid addresses"); + return hleLogError(Log::Mpeg, -1, "UNIMPL / invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); return -1; } //__MpegFinish(); - return hleLogError(Log::ME, 0, "UNIMPL"); + return hleLogError(Log::Mpeg, 0, "UNIMPL"); } static u32 sceMpegAvcCopyYCbCr(u32 mpeg, u32 sourceAddr, u32 YCbCrAddr) { if (!Memory::IsValidAddress(sourceAddr) || !Memory::IsValidAddress(YCbCrAddr)) { - return hleLogError(Log::ME, -1, "UNIMPL / invalid address(es)"); + return hleLogError(Log::Mpeg, -1, "UNIMPL / invalid address(es)"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogError(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogError(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } // This is very common. - return hleLogDebug(Log::ME, 0, "UNIMPL"); + return hleLogDebug(Log::Mpeg, 0, "UNIMPL"); } static u32 sceMpegAtracDecode(u32 mpeg, u32 auAddr, u32 bufferAddr, int init) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } if (!Memory::IsValidAddress(bufferAddr)) { - return hleLogWarning(Log::ME, -1, "invalid addresses"); + return hleLogWarning(Log::Mpeg, -1, "invalid addresses"); } SceMpegAu atracAu; @@ -1861,7 +1861,7 @@ static u32 sceMpegAtracDecode(u32 mpeg, u32 auAddr, u32 bufferAddr, int init) atracAu.write(auAddr); - return hleDelayResult(hleLogDebug(Log::ME, 0), "mpeg atrac decode", atracDecodeDelayMs); + return hleDelayResult(hleLogDebug(Log::Mpeg, 0), "mpeg atrac decode", atracDecodeDelayMs); //hleEatMicro(4000); //return hleDelayResult(0, "mpeg atrac decode", 200); } @@ -1870,12 +1870,12 @@ static u32 sceMpegAtracDecode(u32 mpeg, u32 auAddr, u32 bufferAddr, int init) static u32 sceMpegAvcCsc(u32 mpeg, u32 sourceAddr, u32 rangeAddr, int frameWidth, u32 destAddr) { if (!Memory::IsValidAddress(sourceAddr) || !Memory::IsValidAddress(rangeAddr) || !Memory::IsValidAddress(destAddr)) { - return hleLogError(Log::ME, -1, "invalid addresses"); + return hleLogError(Log::Mpeg, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } if (frameWidth == 0) { @@ -1892,7 +1892,7 @@ static u32 sceMpegAvcCsc(u32 mpeg, u32 sourceAddr, u32 rangeAddr, int frameWidth int height = Memory::Read_U32(rangeAddr + 12); if (x < 0 || y < 0 || width < 0 || height < 0) { - WARN_LOG(Log::ME, "sceMpegAvcCsc(%08x, %08x, %08x, %i, %08x) returning ERROR_INVALID_VALUE", mpeg, sourceAddr, rangeAddr, frameWidth, destAddr); + WARN_LOG(Log::Mpeg, "sceMpegAvcCsc(%08x, %08x, %08x, %i, %08x) returning ERROR_INVALID_VALUE", mpeg, sourceAddr, rangeAddr, frameWidth, destAddr); return SCE_KERNEL_ERROR_INVALID_VALUE; } @@ -1905,52 +1905,52 @@ static u32 sceMpegAvcCsc(u32 mpeg, u32 sourceAddr, u32 rangeAddr, int frameWidth // If do not use DelayResult,Wil cause flickering in Dengeki no Pilot: Tenkuu no Kizuna // https://github.com/hrydgard/ppsspp/issues/7549 - return hleDelayResult(hleLogDebug(Log::ME, 0), "mpeg avc csc", avcCscDelayMs); + return hleDelayResult(hleLogDebug(Log::Mpeg, 0), "mpeg avc csc", avcCscDelayMs); } static u32 sceMpegRingbufferDestruct(u32 ringbufferAddr) { // Apparently, does nothing. - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static u32 sceMpegAvcInitYCbCr(u32 mpeg, int mode, int width, int height, u32 ycbcr_addr) { if (!Memory::IsValidAddress(ycbcr_addr)) { - return hleLogError(Log::ME, -1, "invalid addresses"); + return hleLogError(Log::Mpeg, -1, "invalid addresses"); } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } - WARN_LOG_ONCE(sceMpegAvcInitYCbCr, Log::ME, "UNIMPL sceMpegAvcInitYCbCr(%08x, %i, %i, %i, %08x)", mpeg, mode, width, height, ycbcr_addr); + WARN_LOG_ONCE(sceMpegAvcInitYCbCr, Log::Mpeg, "UNIMPL sceMpegAvcInitYCbCr(%08x, %i, %i, %i, %08x)", mpeg, mode, width, height, ycbcr_addr); return hleNoLog(0); } static int sceMpegAvcQueryYCbCrSize(u32 mpeg, u32 mode, u32 width, u32 height, u32 resultAddr) { if ((width & 15) != 0 || (height & 15) != 0 || height > 272 || width > 480) { - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "sceMpegAvcQueryYCbCrSize: bad w/h %i x %i", width, height); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE, "sceMpegAvcQueryYCbCrSize: bad w/h %i x %i", width, height); } int size = (width / 2) * (height / 2) * 6 + 128; if (Memory::IsValidAddress(resultAddr)) { Memory::WriteUnchecked_U32(size, resultAddr); } - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static u32 sceMpegQueryUserdataEsSize(u32 mpeg, u32 esSizeAddr, u32 outSizeAddr) { if (!Memory::IsValidAddress(esSizeAddr) || !Memory::IsValidAddress(outSizeAddr)) { - ERROR_LOG(Log::ME, "sceMpegQueryUserdataEsSize(%08x, %08x, %08x): invalid addresses", mpeg, esSizeAddr, outSizeAddr); + ERROR_LOG(Log::Mpeg, "sceMpegQueryUserdataEsSize(%08x, %08x, %08x): invalid addresses", mpeg, esSizeAddr, outSizeAddr); return -1; } MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - WARN_LOG(Log::ME, "sceMpegQueryUserdataEsSize(%08x, %08x, %08x): bad mpeg handle", mpeg, esSizeAddr, outSizeAddr); + WARN_LOG(Log::Mpeg, "sceMpegQueryUserdataEsSize(%08x, %08x, %08x): bad mpeg handle", mpeg, esSizeAddr, outSizeAddr); return -1; } @@ -1958,29 +1958,29 @@ static u32 sceMpegQueryUserdataEsSize(u32 mpeg, u32 esSizeAddr, u32 outSizeAddr) Memory::WriteUnchecked_U32(MPEG_DATA_ES_SIZE, esSizeAddr); Memory::WriteUnchecked_U32(MPEG_DATA_ES_OUTPUT_SIZE, outSizeAddr); - return hleLogDebug(Log::ME, 0); + return hleLogDebug(Log::Mpeg, 0); } static u32 sceMpegAvcResourceGetAvcDecTopAddr(u32 mpeg) { // it's just a random address - return hleLogError(Log::ME, 0x12345678, "UNIMPL"); + return hleLogError(Log::Mpeg, 0x12345678, "UNIMPL"); } static u32 sceMpegAvcResourceFinish(u32 mpeg) { - return hleLogInfo(Log::ME, 0, "UNIMPL"); + return hleLogInfo(Log::Mpeg, 0, "UNIMPL"); } static u32 sceMpegAvcResourceGetAvcEsBuf(u32 mpeg) { - ERROR_LOG_REPORT_ONCE(mpegResourceEsBuf, Log::ME, "UNIMPL sceMpegAvcResourceGetAvcEsBuf(%08x)", mpeg); + ERROR_LOG_REPORT_ONCE(mpegResourceEsBuf, Log::Mpeg, "UNIMPL sceMpegAvcResourceGetAvcEsBuf(%08x)", mpeg); return hleNoLog(0); } static u32 sceMpegAvcResourceInit(u32 mpeg) { if (mpeg != 1) { - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE); } - return hleLogError(Log::ME, 0, "UNIMPL"); + return hleLogError(Log::Mpeg, 0, "UNIMPL"); } // TODO: SIMD this (or rather, the caller). @@ -2023,7 +2023,7 @@ static int __MpegAvcConvertToYuv420(const void *data, u32 bufferOutputAddr, int u8 *Cr = Cb + sizeCb; if (!Y) - return hleLogError(Log::ME, 0, "Bad output buffer pointer for yuv conv: %08x", bufferOutputAddr); + return hleLogError(Log::Mpeg, 0, "Bad output buffer pointer for yuv conv: %08x", bufferOutputAddr); for (int y = 0; y < height; y += 2) { for (int x = 0; x < width; x += 2) { @@ -2051,14 +2051,14 @@ static int __MpegAvcConvertToYuv420(const void *data, u32 bufferOutputAddr, int static int sceMpegAvcConvertToYuv420(u32 mpeg, u32 bufferOutputAddr, u32 bufferAddr, int unknown2) { if (!Memory::IsValidAddress(bufferOutputAddr)) - return hleLogError(Log::ME, SCE_MPEG_ERROR_INVALID_VALUE, "invalid addresses"); + return hleLogError(Log::Mpeg, SCE_MPEG_ERROR_INVALID_VALUE, "invalid addresses"); MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); if (ctx->mediaengine->m_buffer == 0) - return hleLogWarning(Log::ME, SCE_MPEG_ERROR_AVC_INVALID_VALUE, "m_buffer is zero"); + return hleLogWarning(Log::Mpeg, SCE_MPEG_ERROR_AVC_INVALID_VALUE, "m_buffer is zero"); const u8 *data = ctx->mediaengine->getFrameImage(); int width = ctx->mediaengine->m_desWidth; @@ -2067,13 +2067,13 @@ static int sceMpegAvcConvertToYuv420(u32 mpeg, u32 bufferOutputAddr, u32 bufferA if (data) { __MpegAvcConvertToYuv420(data, bufferOutputAddr, width, height); } - return hleLogDebug(Log::ME, (width << 16) | height); + return hleLogDebug(Log::Mpeg, (width << 16) | height); } static int sceMpegGetUserdataAu(u32 mpeg, u32 streamUid, u32 auAddr, u32 resultAddr) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "bad mpeg handle"); } if (Memory::IsValidRange(resultAddr, 8)) { @@ -2084,76 +2084,76 @@ static int sceMpegGetUserdataAu(u32 mpeg, u32 streamUid, u32 auAddr, u32 resultA // We currently can't demux userdata so this seems like the best thing to return in the meantime.. // Then we probably shouldn't do the above writes? but it works... - return hleLogDebug(Log::ME, SCE_MPEG_ERROR_NO_DATA); + return hleLogDebug(Log::Mpeg, SCE_MPEG_ERROR_NO_DATA); } static u32 sceMpegNextAvcRpAu(u32 mpeg, u32 streamUid) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } - ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegNextAvcRpAu(%08x, %08x)", mpeg, streamUid); + ERROR_LOG_REPORT(Log::Mpeg, "UNIMPL sceMpegNextAvcRpAu(%08x, %08x)", mpeg, streamUid); return 0; } static u32 sceMpegGetAvcNalAu(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } - ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegGetAvcNalAu(%08x)", mpeg); + ERROR_LOG_REPORT(Log::Mpeg, "UNIMPL sceMpegGetAvcNalAu(%08x)", mpeg); return 0; } static u32 sceMpegAvcDecodeDetailIndex(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } - ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegAvcDecodeDetailIndex(%08x)", mpeg); + ERROR_LOG_REPORT(Log::Mpeg, "UNIMPL sceMpegAvcDecodeDetailIndex(%08x)", mpeg); return 0; } static u32 sceMpegAvcDecodeDetail2(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } - ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegAvcDecodeDetail2(%08x)", mpeg); + ERROR_LOG_REPORT(Log::Mpeg, "UNIMPL sceMpegAvcDecodeDetail2(%08x)", mpeg); return 0; } static u32 sceMpegGetAvcEsAu(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } - ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegGetAvcEsAu(%08x)", mpeg); + ERROR_LOG_REPORT(Log::Mpeg, "UNIMPL sceMpegGetAvcEsAu(%08x)", mpeg); return 0; } static u32 sceMpegAvcCscInfo(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } - ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegAvcCscInfo(%08x)", mpeg); + ERROR_LOG_REPORT(Log::Mpeg, "UNIMPL sceMpegAvcCscInfo(%08x)", mpeg); return 0; } static u32 sceMpegAvcCscMode(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } - ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegAvcCscMode(%08x)", mpeg); + ERROR_LOG_REPORT(Log::Mpeg, "UNIMPL sceMpegAvcCscMode(%08x)", mpeg); return 0; } @@ -2161,10 +2161,10 @@ static u32 sceMpegFlushAu(u32 mpeg) { MpegContext *ctx = getMpegCtx(mpeg); if (!ctx) { - return hleLogWarning(Log::ME, -1, "UNIMPL / bad mpeg handle"); + return hleLogWarning(Log::Mpeg, -1, "UNIMPL / bad mpeg handle"); } - ERROR_LOG_REPORT(Log::ME, "UNIMPL sceMpegFlushAu(%08x)", mpeg); + ERROR_LOG_REPORT(Log::Mpeg, "UNIMPL sceMpegFlushAu(%08x)", mpeg); return 0; } @@ -2254,7 +2254,7 @@ static u32 sceMpegBasePESpacketCopy(u32 p) ++lli; } - DEBUG_LOG(Log::ME, "sceMpegBasePESpacketCopy(%08x), received %d block(s)", pmp_videoSource, pmp_nBlocks); + DEBUG_LOG(Log::Mpeg, "sceMpegBasePESpacketCopy(%08x), received %d block(s)", pmp_videoSource, pmp_nBlocks); return 0; } diff --git a/Core/HLE/sceReg.cpp b/Core/HLE/sceReg.cpp index cb2249f8dcfa..b70ea5eb42df 100644 --- a/Core/HLE/sceReg.cpp +++ b/Core/HLE/sceReg.cpp @@ -486,6 +486,8 @@ const KeyValue ROOT[] = { { "SYSPROFILE", ValueType::DIR, "", ARRAY_SIZE(tree_SYSPROFILE), tree_SYSPROFILE }, }; +// Updater checks for CONFIG/SYSTEM/XMB. + void __RegInit() { g_openRegistryMode = 0; g_handleGen = 1337; @@ -522,7 +524,7 @@ static const KeyValue *LookupCategory(std::string_view path, int *count) { } } if (!found) { - WARN_LOG(Log::sceReg, "Path not found: %.*s", (int)path.size(), path.data()); + WARN_LOG(Log::sceReg, "LookupCategory: Path not found: %.*s", (int)path.size(), path.data()); return nullptr; } } diff --git a/Core/MIPS/JitCommon/JitBlockCache.cpp b/Core/MIPS/JitCommon/JitBlockCache.cpp index 31bd2029ad85..a68c52a274da 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.cpp +++ b/Core/MIPS/JitCommon/JitBlockCache.cpp @@ -235,6 +235,7 @@ void JitBlockCache::RemoveBlockMap(int block_num) { block_map_.erase(it); } else { // It wasn't in there, or it has the wrong key. Let's search... + // TODO: This is O(n), so O(n^2) when called for every block. for (auto it = block_map_.begin(); it != block_map_.end(); ++it) { if (it->second == (u32)block_num) { block_map_.erase(it); diff --git a/Core/System.cpp b/Core/System.cpp index fdc439e380da..627c4c686d82 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -295,7 +295,7 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin // TODO: Better would be to check that it was loaded successfully. if (!File::Exists(g_CoreParameter.fileToStart / INDEX_FILENAME)) { auto sc = GetI18NCategory(I18NCat::SCREEN); - g_OSD.Show(OSDType::MESSAGE_CENTERED_WARNING, sc->T("ExtractedIsoWarning", "Extracted ISOs often don't work.\nPlay the ISO file directly."), g_CoreParameter.fileToStart.ToVisualString(), 7.0f); + g_OSD.Show(OSDType::MESSAGE_WARNING, sc->T("ExtractedIsoWarning", "Extracted ISOs often don't work.\nPlay the ISO file directly."), g_CoreParameter.fileToStart.ToVisualString(), 7.0f); } else { INFO_LOG(Log::Loader, "Extracted ISO loaded without warning - %s is present.", INDEX_FILENAME.c_str()); } @@ -950,7 +950,7 @@ void DumpFileIfEnabled(const u8 *dataPtr, const u32 length, std::string_view nam fwrite(dataPtr, sizeof(u8), lengthToWrite, file); fclose(file); - INFO_LOG(Log::sceModule, "Successfully wrote %s to %s", DumpFileTypeToString(type), fullPath.c_str()); + INFO_LOG(Log::sceModule, "Successfully wrote %s to %s", DumpFileTypeToString(type), fullPath.ToVisualString().c_str()); char *path = new char[strlen(fullPath.c_str()) + 1]; strcpy(path, fullPath.c_str()); diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 47c6f202a34b..a5459bbad9b0 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -1096,6 +1096,14 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) { ImGui::Checkbox("", mutePtr); } ImGui::TableNextColumn(); + + const AtracBase *ctx = __AtracGetCtx(i, &codecType); + if (!ctx) { + // Nothing more we can display about uninitialized contexts. + ImGui::PopID(); + continue; + } + switch (codecType) { case 0: ImGui::TextUnformatted("-"); // Uninitialized @@ -1111,12 +1119,6 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) { break; } - const AtracBase *ctx = __AtracGetCtx(i, &codecType); - if (!ctx) { - // Nothing more we can display about uninitialized contexts. - ImGui::PopID(); - continue; - } ImGui::TableNextColumn(); ImGui::TextUnformatted(AtracStatusToString(ctx->BufferState())); ImGui::TableNextColumn(); diff --git a/ext/imgui/imgui_impl_platform.cpp b/ext/imgui/imgui_impl_platform.cpp index 67450945d702..562d0ed72202 100644 --- a/ext/imgui/imgui_impl_platform.cpp +++ b/ext/imgui/imgui_impl_platform.cpp @@ -247,6 +247,10 @@ ImGuiKey KeyCodeToImGui(InputKeyCode keyCode) { case NKCODE_EXT_PRINTSCREEN: return ImGuiKey_PrintScreen; + case NKCODE_EXT_PIPE: + // No valid mapping exists. + return ImGuiKey_None; + default: WARN_LOG(Log::System, "Unmapped ImGui keycode conversion from %d", keyCode); return ImGuiKey_None; diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 7d45bcfd1d0d..352b397c8a88 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -503,9 +503,10 @@ int main(int argc, const char* argv[]) coreParameter.pixelHeight = 272; coreParameter.fastForward = true; + g_Config.iDumpFileTypes = 0; g_Config.bEnableSound = false; g_Config.bFirstRun = false; - g_Config.bIgnoreBadMemAccess = true; + g_Config.bIgnoreBadMemAccess = true; // NOTE: A few tests rely on this, which is BAD: threads/mbx/refer/refer , threads/mbx/send/send, threads/vtimers/interrupt // Never report from tests. g_Config.sReportHost.clear(); g_Config.bAutoSaveSymbolMap = false; @@ -542,6 +543,7 @@ int main(int argc, const char* argv[]) g_Config.internalDataDirectory.clear(); g_Config.bUseOldAtrac = oldAtrac; g_Config.iForceEnableHLE = 0xFFFFFFFF; // Run all modules as HLE. We don't have anything to load in this context. + // g_Config.bUseOldAtrac = true; Path exePath = File::GetExeDirectory(); g_Config.flash0Directory = exePath / "assets/flash0";