made savestates synchronous and immediate. this allows saving or loading while the emulator is paused, fixes issues where savestate hotkeys would get ignored if pressed too close together, might speed up savestates in some cases, and hopefully makes savestates more stable too.

the intent is to replace the haphazard scheduling and finger-crossing associated with saving/loading with the correct and minimal necessary wait for each thread to reach a known safe location before commencing the savestate operation, and for any already-paused components to not need to be resumed to do so.
This commit is contained in:
nitsuja
2011-12-30 20:16:12 -08:00
committed by skidau
parent 108f69eaa9
commit a81631b58e
33 changed files with 518 additions and 323 deletions

View File

@ -118,4 +118,23 @@ namespace AudioCommon
bool UseJIT() {
return ac_Config.m_EnableJIT;
}
void PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
if (soundStream)
{
// audio typically doesn't maintain its own "paused" state
// (that's already handled by the CPU and whatever else being paused)
// so it should be good enough to only lock/unlock here.
CMixer* pMixer = soundStream->GetMixer();
if (pMixer)
{
std::mutex& csMixing = pMixer->MixerCritical();
if (doLock)
csMixing.lock();
else
csMixing.unlock();
}
}
}
}