Merge pull request #20126 from hrydgard/atrac3-followup

Fix a crash in sceAtrac sas integration
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2025-03-18 15:15:46 +01:00
commit bb0123a25e
7 files changed
+17 -24

No files matched your search

+1 -11
View File
@@ -85,20 +85,10 @@ void GenericLog(LogLevel level, Log type, const char *file, int line, const char
;
bool GenericLogEnabled(LogLevel level, Log type);
// We only disable DEBUG and VERBOSE on Android/iOS now.
#if defined(_DEBUG) || (!PPSSPP_PLATFORM(ANDROID) && !PPSSPP_PLATFORM(IOS))
// If you want to see verbose logs, change this to VERBOSE_LEVEL.
// Needs to be an int (and not use the enum) because it's used by the preprocessor!
#define MAX_LOGLEVEL DEBUG_LEVEL
#else
#ifndef MAX_LOGLEVEL
#define MAX_LOGLEVEL INFO_LEVEL
#endif // loglevel
#endif // logging
// Let the compiler optimize this out.
// TODO: Compute a dynamic max level as well that can be checked here.
#define GENERIC_LOG(t, v, ...) { \
+7 -6
View File
@@ -1092,17 +1092,18 @@ u32 AtracSasDecodeData(int atracID, u8* outbuf, u32 outbufPtr, u32 *SamplesNum,
// Ugly hack, but needed to support both old and new contexts.
int AtracSasGetIDByContext(u32 contextAddr) {
int atracID = (int)Memory::Read_U32(contextAddr + 0xfc);
if (atracID < PSP_MAX_ATRAC_IDS && atracContexts[atracID]->GetContextVersion() == 1) {
if (atracID < PSP_MAX_ATRAC_IDS && atracContexts[atracID] && atracContexts[atracID]->GetContextVersion() == 1) {
// We can assume the old atracID hack was used, and atracID is valid.
} else {
// Let's just loop around the contexts and find it.
atracID = -1;
for (int i = 0; i < PSP_MAX_ATRAC_IDS; i++) {
if (atracContexts[i]) {
if (atracContexts[i]->GetContextVersion() == 2 && atracContexts[i]->context_.Equals(contextAddr)) {
atracID = i;
break;
}
if (!atracContexts[i]) {
continue;
}
if (atracContexts[i]->GetContextVersion() == 2 && atracContexts[i]->context_.Equals(contextAddr)) {
atracID = i;
break;
}
}
_dbg_assert_(atracID != -1);
+3 -2
View File
@@ -2194,7 +2194,7 @@ static u32 sceIoOpenAsync(const char *filename, int flags, int mode) {
FileNode *f = __IoOpen(error, filename, flags, mode);
// We have to return an fd here, which may have been destroyed when we reach Wait if it failed.
if (f == nullptr) {
if (!f) {
_assert_(error != 0);
if (error == SCE_KERNEL_ERROR_NODEV)
return hleLogError(Log::sceIo, error, "device not found");
@@ -2223,7 +2223,8 @@ static u32 sceIoOpenAsync(const char *filename, int flags, int mode) {
if (error != 0) {
f->asyncResult = (s64)error;
return hleLogError(Log::sceIo, fd, "file not found");
// This is not necessarily an error, a lot of games check for the presence of files and are fine with no.
return hleLogWarning(Log::sceIo, fd, "file not found");
}
f->asyncResult = fd;
+1 -1
View File
@@ -2283,7 +2283,7 @@ static u32 sceKernelStartModule(u32 moduleId, u32 argsize, u32 argAddr, u32 retu
} else if (module->isFake) {
if (returnValueAddr)
Memory::Write_U32(0, returnValueAddr);
return hleLogInfo(Log::sceModule, moduleId, "Faked (undecryptable module)");
return hleLogInfo(Log::sceModule, moduleId, "Faked module");
} else if (module->nm.status == MODULE_STATUS_STARTED) {
// TODO: Maybe should be SCE_KERNEL_ERROR_ALREADY_STARTED, but I get SCE_KERNEL_ERROR_ERROR.
// But I also get crashes...
+2 -2
View File
@@ -1753,10 +1753,10 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
void EmuScreen::runImDebugger() {
if (!lastImguiEnabled_ && g_Config.bShowImDebugger) {
System_NotifyUIEvent(UIEventNotification::TEXT_GOTFOCUS);
INFO_LOG(Log::System, "activating keyboard");
VERBOSE_LOG(Log::System, "activating keyboard");
} else if (lastImguiEnabled_ && !g_Config.bShowImDebugger) {
System_NotifyUIEvent(UIEventNotification::TEXT_LOSTFOCUS);
INFO_LOG(Log::System, "deactivating keyboard");
VERBOSE_LOG(Log::System, "deactivating keyboard");
}
lastImguiEnabled_ = g_Config.bShowImDebugger;
if (g_Config.bShowImDebugger) {
+2 -1
View File
@@ -164,7 +164,8 @@ struct ImConfig {
int selectedBreakpoint = -1;
int selectedMemCheck = -1;
int selectedAtracCtx = 0;
u32 selectedMemoryBlock = 0;
int selectedMemoryBlock = 0;
uint64_t selectedTexAddr = 0;
bool realtimePixelPreview = false;
+1 -1
View File
@@ -1071,7 +1071,7 @@ void NativeFrame(GraphicsContext *graphicsContext) {
for (const auto &item : toProcess) {
if (HandleGlobalMessage(item.message, item.value)) {
// TODO: Add a to-string thingy.
INFO_LOG(Log::System, "Handled global message: %d / %s", (int)item.message, item.value.c_str());
VERBOSE_LOG(Log::System, "Handled global message: %d / %s", (int)item.message, item.value.c_str());
}
g_screenManager->sendMessage(item.message, item.value.c_str());
}