Do not allow to unpause after fatal error occured in emulation

* Plus fix #10590
This commit is contained in:
Eladash 2021-09-07 19:42:08 +03:00 committed by Megamouse
parent 69faf14a79
commit bd66dfedc9
5 changed files with 26 additions and 9 deletions

View file

@ -1404,17 +1404,27 @@ void Emulator::Run(bool start_playtime)
}
}
bool Emulator::Pause()
bool Emulator::Pause(bool freeze_emulation)
{
const u64 start = get_system_time();
const system_state pause_state = freeze_emulation ? system_state::frozen : system_state::paused;
// Try to pause
if (!m_state.compare_and_swap_test(system_state::running, system_state::paused))
if (!m_state.compare_and_swap_test(system_state::running, pause_state))
{
if (!m_state.compare_and_swap_test(system_state::ready, system_state::paused))
if (!freeze_emulation)
{
return false;
}
if (!m_state.compare_and_swap_test(system_state::ready, pause_state))
{
if (!m_state.compare_and_swap_test(system_state::paused, pause_state))
{
return false;
}
}
}
// Signal profilers to print results (if enabled)
@ -1424,7 +1434,14 @@ bool Emulator::Pause()
static atomic_t<u32> pause_mark = 0;
sys_log.success("Emulation is being paused... (mark=%u)", pause_mark++);
if (freeze_emulation)
{
sys_log.warning("Emulation has been frozen! You can either use debugger tools to inspect current emulation state or terminate it.");
}
else
{
sys_log.success("Emulation is being paused... (mark=%u)", pause_mark++);
}
// Update pause start time
if (m_pause_start_time.exchange(start))