diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 93db0fc28fe..81f1695ea94 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -768,42 +768,26 @@ void SaveScreenShot(std::string_view name) g_frame_dumper->SaveScreenshot(fmt::format("{}{}.png", GenerateScreenshotFolderPath(), name)); } -static bool PauseAndLock(Core::System& system, bool do_lock, bool unpause_on_unlock) +static bool PauseAndLock(Core::System& system) { // WARNING: PauseAndLock is not fully threadsafe so is only valid on the Host Thread if (!IsRunning(system)) return true; - bool was_unpaused = true; - if (do_lock) - { - // first pause the CPU - // This acquires a wrapper mutex and converts the current thread into - // a temporary replacement CPU Thread. - was_unpaused = system.GetCPU().PauseAndLock(); - } + // First pause the CPU. This acquires a wrapper mutex and converts the current thread into + // a temporary replacement CPU Thread. + const bool was_unpaused = system.GetCPU().PauseAndLock(); // audio has to come after CPU, because CPU thread can wait for audio thread (m_throttle). - system.GetDSP().GetDSPEmulator()->PauseAndLock(do_lock); + system.GetDSP().GetDSPEmulator()->PauseAndLock(true); // video has to come after CPU, because CPU thread can wait for video thread // (s_efbAccessRequested). - system.GetFifo().PauseAndLock(do_lock, false); + system.GetFifo().PauseAndLock(true, false); ResetRumble(); - // CPU is unlocked last because CPU::PauseAndLock contains the synchronization - // mechanism that prevents CPU::Break from racing. - if (!do_lock) - { - // The CPU is responsible for managing the Audio and FIFO state so we use its - // mechanism to unpause them. If we unpaused the systems above when releasing - // the locks then they could call CPU::Break which would require detecting it - // and re-pausing with CPU::SetStepping. - system.GetCPU().RestoreStateAndUnlock(unpause_on_unlock); - } - return was_unpaused; } @@ -838,7 +822,7 @@ void RunOnCPUThread(Core::System& system, Common::MoveOnlyFunction funct } // Pause the CPU (set it to stepping mode). - const bool was_running = PauseAndLock(system, true, true); + const bool was_running = PauseAndLock(system); // Queue the job function. if (wait_for_completion) @@ -1073,7 +1057,7 @@ CPUThreadGuard::CPUThreadGuard(Core::System& system) : m_system(system), m_was_cpu_thread(IsCPUThread()) { if (!m_was_cpu_thread) - m_was_unpaused = PauseAndLock(system, true, true); + m_was_unpaused = PauseAndLock(system); } CPUThreadGuard::~CPUThreadGuard()