diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index a5870f87c32f..5e22b7aeb6a7 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -126,10 +126,9 @@ namespace Reporting return 0; } - void QueueCRC() { + void QueueCRC(const std::string &gamePath) { std::lock_guard guard(crcLock); - const std::string &gamePath = PSP_CoreParameter().fileToStart; auto it = crcResults.find(gamePath); if (it != crcResults.end()) { // Nothing to do, we've already calculated it. @@ -146,9 +145,15 @@ namespace Reporting crcThread = std::thread(CalculateCRCThread); } - u32 RetrieveCRC() { - const std::string &gamePath = PSP_CoreParameter().fileToStart; - QueueCRC(); + bool HasCRC(const std::string &gamePath) { + QueueCRC(gamePath); + + std::lock_guard guard(crcLock); + return crcResults.find(gamePath) != crcResults.end(); + } + + uint32_t RetrieveCRC(const std::string &gamePath) { + QueueCRC(gamePath); std::unique_lock guard(crcLock); auto it = crcResults.find(gamePath); @@ -468,7 +473,7 @@ namespace Reporting postdata.Add("graphics", StringFromFormat("%d", payload.int1)); postdata.Add("speed", StringFromFormat("%d", payload.int2)); postdata.Add("gameplay", StringFromFormat("%d", payload.int3)); - postdata.Add("crc", StringFromFormat("%08x", Core_GetPowerSaving() ? 0 : RetrieveCRC())); + postdata.Add("crc", StringFromFormat("%08x", Core_GetPowerSaving() ? 0 : RetrieveCRC(PSP_CoreParameter().fileToStart))); postdata.Add("suggestions", payload.string1 != "perfect" && payload.string1 != "playable" ? "1" : "0"); AddScreenshotData(postdata, payload.string2); payload.string1.clear(); diff --git a/Core/Reporting.h b/Core/Reporting.h index 50b24f93c8bb..87a6d186a45c 100644 --- a/Core/Reporting.h +++ b/Core/Reporting.h @@ -87,6 +87,13 @@ namespace Reporting // Get the latest compatibility result. Only valid when GetStatus() is not BUSY. std::vector CompatibilitySuggestions(); + // Queues game for CRC hash if needed, and returns true if the hash is available. + bool HasCRC(const std::string &gamePath); + + // Blocks until the CRC hash is available for game, and returns it. + // To avoid stalling, call HasCRC() in update() or similar and call this if it returns true. + uint32_t RetrieveCRC(const std::string &gamePath); + // Returns true if that identifier has not been logged yet. bool ShouldLogNTimes(const char *identifier, int n);