diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 675fcb36ca..27607781af 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -1306,13 +1306,19 @@ u32 CPUDisAsm::DisAsmBranchTarget(s32 /*imm*/) return 0; } -extern bool try_lock_spu_threads_in_a_state_compatible_with_savestates() +extern bool try_lock_spu_threads_in_a_state_compatible_with_savestates(bool revert_lock) { const u64 start = get_system_time(); // Attempt to lock for half a second, if somehow takes longer abort it do { + if (revert_lock) + { + // Revert the operation of this function + break; + } + if (cpu_thread::suspend_all(nullptr, {}, []() { return idm::select>([](u32, spu_thread& spu) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 62fca14117..541465f5c3 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -2222,7 +2222,7 @@ void Emulator::GracefulShutdown(bool allow_autoexit, bool async_op, bool savesta } extern bool try_lock_vdec_context_creation(); -extern bool try_lock_spu_threads_in_a_state_compatible_with_savestates(); +extern bool try_lock_spu_threads_in_a_state_compatible_with_savestates(bool revert_lock = false); std::shared_ptr Emulator::Kill(bool allow_autoexit, bool savestate) { @@ -2235,6 +2235,8 @@ std::shared_ptr Emulator::Kill(bool allow_autoexit, bool savestat if (savestate && !try_lock_vdec_context_creation()) { + try_lock_spu_threads_in_a_state_compatible_with_savestates(true); + sys_log.error("Failed to savestate: HLE VDEC (video decoder) context(s) exist." "\nLLE libvdec.sprx by selecting it in Adavcned tab -> Firmware Libraries." "\nYou need to close the game for to take effect."