| 1648 | } |
| 1649 | |
| 1650 | void 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(); |
no test coverage detected