Block until game info is ready in LaunchFile

When launching a file from outside the main screen (file association, shortcut,
drag-and-drop), the info hasn't been computed yet, so the file type and ID checks
that decide what to do with the file were reading empty data. Add
GameInfo::WaitUntilReady() - a condition variable signalled from
MarkReadyNoLock(), which every exit path of the work item goes through - and use
it there.

Also demote a noisy PRX decryption log line to DEBUG.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EMLTdwyyzU6Mze3w8VC2JL
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-08-24 17:23:20 +02:00
1 parent cc1cdfcec4
commit 65592effc5
3 files changed
+25 -5

No files matched your search

+2 -3
View File
@@ -769,9 +769,8 @@ struct PRXType9
};
static_assert(sizeof(PRXType9) == 0x150, "inconsistent size of PRX Type 9");
static int pspDecryptType0(KirkState *kirk, const u8 *inbuf, u8 *outbuf, u32 size)
{
INFO_LOG(Log::Loader, "Decrypting tag %02X", (u32)*(u32_le *)&inbuf[0xD0]);
static int pspDecryptType0(KirkState *kirk, const u8 *inbuf, u8 *outbuf, u32 size) {
DEBUG_LOG(Log::Loader, "Decrypting tag %02X", (u32)*(u32_le *)&inbuf[0xD0]);
const auto decryptSize = *(s32_le*)&inbuf[0xB0];
const auto pti = GetTagInfo((u32)*(u32_le *)&inbuf[0xD0]);
+18
View File
@@ -22,6 +22,7 @@
#include <memory>
#include <mutex>
#include <atomic>
#include <condition_variable>
#include "Common/Thread/Event.h"
#include "Core/ELF/ParamSFO.h"
@@ -123,9 +124,23 @@ public:
return ((int)hasFlags & (int)flags) == (int)flags;
}
// Blocks the calling thread until the specified flags have been loaded. Note that you must
// have requested them through GetInfo first, otherwise nobody will ever compute them and
// this will simply hang.
// Only use this where there's really no way to wait asynchronously by polling Ready() every
// frame - loading can take a while, especially from slow or remote storage.
void WaitUntilReady(GameInfoFlags flags) {
std::unique_lock<std::mutex> guard(lock);
readyCond.wait(guard, [this, flags]() {
// Avoid the operator, we want to check all the bits.
return ((int)hasFlags & (int)flags) == (int)flags;
});
}
void MarkReadyNoLock(GameInfoFlags flags) {
hasFlags |= flags;
pendingFlags &= ~flags;
readyCond.notify_all();
}
GameInfoTex *GetPIC1() {
@@ -140,6 +155,9 @@ public:
// to it.
std::mutex lock;
// Signalled whenever flags are marked as ready, see WaitUntilReady. Goes with the lock above.
std::condition_variable readyCond;
// Controls access to the fileLoader pointer.
std::mutex loaderLock;
+5 -2
View File
@@ -70,8 +70,11 @@ static void LaunchFile(ScreenManager *screenManager, Screen *currentScreen, cons
} else {
// Check if we already know that this game isn't playable.
// If coming from the main screen, the info will already be computed here since the icon is displayed etc.
// Otherwise, we probably technically should wait for it...
auto info = g_gameInfoCache->GetInfo(nullptr, path, GameInfoFlags::FILE_TYPE | GameInfoFlags::PARAM_SFO);
// Otherwise (launching from a file association, a shortcut, drag-and-drop...) we have to block until
// it's available - we can't decide what to do below without it.
const GameInfoFlags neededFlags = GameInfoFlags::FILE_TYPE | GameInfoFlags::PARAM_SFO;
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(nullptr, path, neededFlags);
info->WaitUntilReady(neededFlags);
switch (info->fileType) {
case IdentifiedFileType::PSP_UMD_VIDEO_ISO: