Reporting: Expose CRC queue methods for other uses.

This way UI can expose the CRC if needed.
This commit is contained in:
Unknown W. Brackets committed 2021-01-24 19:53:47 -08:00
1 parent a88f6b45d2
commit acbe0573fa
2 files changed
+18 -6

No files matched your search

+11 -6
View File
@@ -126,10 +126,9 @@ namespace Reporting
return 0;
}
void QueueCRC() {
void QueueCRC(const std::string &gamePath) {
std::lock_guard<std::mutex> 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<std::mutex> guard(crcLock);
return crcResults.find(gamePath) != crcResults.end();
}
uint32_t RetrieveCRC(const std::string &gamePath) {
QueueCRC(gamePath);
std::unique_lock<std::mutex> 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();
+7
View File
@@ -87,6 +87,13 @@ namespace Reporting
// Get the latest compatibility result. Only valid when GetStatus() is not BUSY.
std::vector<std::string> 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);