SaveState: Retry failed state screenshots.

See #10815 - happens when the device is resized before the save state.
This commit is contained in:
Unknown W. Brackets 2018-11-25 08:20:23 -08:00
parent 036baf04d0
commit b8b4763ef2

View File

@ -240,6 +240,7 @@ namespace SaveState
static bool needsProcess = false;
static std::vector<Operation> pending;
static std::mutex mutex;
static int screenshotFailures = 0;
static bool hasLoadedState = false;
static const int STALE_STATE_USES = 2;
// 4 hours of total gameplay since the virtual PSP started the game.
@ -249,6 +250,7 @@ namespace SaveState
// TODO: Should this be configurable?
static const int REWIND_NUM_STATES = 20;
static const int SCREENSHOT_FAILURE_RETRIES = 15;
static StateRingbuffer rewindStates(REWIND_NUM_STATES);
// TODO: Any reason for this to be configurable?
const static float rewindMaxWallFrequency = 1.0f;
@ -852,6 +854,12 @@ namespace SaveState
callbackResult = tempResult ? Status::SUCCESS : Status::FAILURE;
if (!tempResult) {
ERROR_LOG(SAVESTATE, "Failed to take a screenshot for the savestate! %s", op.filename.c_str());
if (screenshotFailures++ < SCREENSHOT_FAILURE_RETRIES) {
// Requeue for next frame.
SaveScreenshot(op.filename, op.callback, op.cbUserData);
}
} else {
screenshotFailures = 0;
}
break;
}