MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Shutdown

Method Shutdown

pcsx2/VMManager.cpp:1650–1745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1648}
1649
1650void VMManager::Shutdown(bool save_resume_state)
1651{
1652 // we'll probably already be stopping (this is how Qt calls shutdown),
1653 // but just in case, so any of the stuff we call here knows we don't have a valid VM.
1654 s_state.store(VMState::Stopping, std::memory_order_release);
1655
1656 SetTimerResolutionIncreased(false);
1657
1658 // sync everything
1659 if (THREAD_VU1)
1660 vu1Thread.WaitVU();
1661 MTGS::WaitGS();
1662
1663 if (!GSDumpReplayer::IsReplayingDump() && save_resume_state)
1664 {
1665 std::string resume_file_name(GetCurrentSaveStateFileName(-1));
1666 if (!resume_file_name.empty())
1667 {
1668 DoSaveState(resume_file_name.c_str(), -1, true, false, [](const std::string& error) {
1669 Host::AddIconOSDMessage("SaveResumeState", ICON_FA_TRIANGLE_EXCLAMATION,
1670 fmt::format(TRANSLATE_FS("VMManager", "Failed to save resume state: {}"), error), Host::OSD_QUICK_DURATION);
1671 });
1672 }
1673 }
1674
1675 // end input recording before clearing state
1676 if (g_InputRecording.isActive())
1677 g_InputRecording.stop();
1678
1679 SaveSessionTime(s_disc_serial);
1680 s_elf_override = {};
1681 ClearELFInfo();
1682 CDVDsys_ClearFiles();
1683
1684 {
1685 std::unique_lock lock(s_info_mutex);
1686 ClearDiscDetails();
1687 }
1688
1689 Achievements::GameChanged(0, 0);
1690 FullscreenUI::GameChanged(s_title, std::string(), s_disc_serial, 0, 0);
1691 UpdateDiscordPresence(true);
1692 Host::OnGameChanged(s_title, std::string(), std::string(), s_disc_serial, 0, 0);
1693
1694 s_fast_boot_requested = false;
1695
1696 UpdateGameSettingsLayer();
1697
1698 FPControlRegister::SetCurrent(FPControlRegister::GetDefault());
1699
1700 Patch::UnloadPatches();
1701 R3000A::ioman::reset();
1702 vtlb_Shutdown();
1703 USBclose();
1704 SPU2::Close();
1705 Pad::Shutdown();
1706 g_Sio2.Shutdown();
1707 g_Sio0.Shutdown();

Callers 2

InitializeMethod · 0.45
ShutdownCPUProvidersMethod · 0.45

Calls 15

CDVDsys_ClearFilesFunction · 0.85
vtlb_ShutdownFunction · 0.85
USBcloseFunction · 0.85
DEV9closeFunction · 0.85
DoCDVDcloseFunction · 0.85
FWcloseFunction · 0.85
FileMcd_EmuCloseFunction · 0.85
DEV9shutdownFunction · 0.85
cdvdSaveNVRAMFunction · 0.85
cdvdUnlockFunction · 0.85
WaitVUMethod · 0.80
isActiveMethod · 0.80

Tested by

no test coverage detected