Core: Remove unnecessary PauseAndLock parameters

PauseAndLock is now only called with do_lock=true, and unpause_on_unlock
only ever was used when do_lock is false (which is now handled in
RestoreStateAndUnlock instead), so both parameters are unnecessary.
This commit is contained in:
Dentomologist
2025-10-26 18:01:51 -07:00
parent c9c8461d36
commit 2d888ea4d3
+7 -23
View File
@@ -768,42 +768,26 @@ void SaveScreenShot(std::string_view name)
g_frame_dumper->SaveScreenshot(fmt::format("{}{}.png", GenerateScreenshotFolderPath(), 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 // WARNING: PauseAndLock is not fully threadsafe so is only valid on the Host Thread
if (!IsRunning(system)) if (!IsRunning(system))
return true; return true;
bool was_unpaused = true; // First pause the CPU. This acquires a wrapper mutex and converts the current thread into
if (do_lock)
{
// first pause the CPU
// This acquires a wrapper mutex and converts the current thread into
// a temporary replacement CPU Thread. // a temporary replacement CPU Thread.
was_unpaused = system.GetCPU().PauseAndLock(); const bool was_unpaused = system.GetCPU().PauseAndLock();
}
// audio has to come after CPU, because CPU thread can wait for audio thread (m_throttle). // 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 // video has to come after CPU, because CPU thread can wait for video thread
// (s_efbAccessRequested). // (s_efbAccessRequested).
system.GetFifo().PauseAndLock(do_lock, false); system.GetFifo().PauseAndLock(true, false);
ResetRumble(); 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; return was_unpaused;
} }
@@ -838,7 +822,7 @@ void RunOnCPUThread(Core::System& system, Common::MoveOnlyFunction<void()> funct
} }
// Pause the CPU (set it to stepping mode). // 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. // Queue the job function.
if (wait_for_completion) if (wait_for_completion)
@@ -1073,7 +1057,7 @@ CPUThreadGuard::CPUThreadGuard(Core::System& system)
: m_system(system), m_was_cpu_thread(IsCPUThread()) : m_system(system), m_was_cpu_thread(IsCPUThread())
{ {
if (!m_was_cpu_thread) if (!m_was_cpu_thread)
m_was_unpaused = PauseAndLock(system, true, true); m_was_unpaused = PauseAndLock(system);
} }
CPUThreadGuard::~CPUThreadGuard() CPUThreadGuard::~CPUThreadGuard()