Savestates: safe saving while cellSaveData is active

This commit is contained in:
Eladash 2024-03-27 14:44:33 +02:00 committed by Elad Ashkenazi
parent 9c9ece3d95
commit 7468d96c51
8 changed files with 172 additions and 40 deletions

View file

@ -3,6 +3,7 @@
#include "Emu/VFS.h"
#include "Emu/IdManager.h"
#include "Emu/localized_string.h"
#include "Emu/savestate_utils.hpp"
#include "Emu/Cell/lv2/sys_fs.h"
#include "Emu/Cell/lv2/sys_sync.h"
#include "Emu/Cell/lv2/sys_process.h"
@ -272,6 +273,14 @@ static std::vector<SaveDataEntry> get_save_entries(const std::string& base_dir,
static error_code select_and_delete(ppu_thread& ppu)
{
std::unique_lock hle_lock(g_fxo->get<hle_locks_t>(), std::try_to_lock);
if (!hle_lock)
{
ppu.state += cpu_flag::again;
return {};
}
std::unique_lock lock(g_fxo->get<savedata_manager>().mutex, std::try_to_lock);
if (!lock)
@ -699,6 +708,14 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
return {CELL_SAVEDATA_ERROR_PARAM, " (error %d)", ecode};
}
std::unique_lock hle_lock(g_fxo->get<hle_locks_t>(), std::try_to_lock);
if (!hle_lock)
{
ppu.state += cpu_flag::again;
return {};
}
std::unique_lock lock(g_fxo->get<savedata_manager>().mutex, std::try_to_lock);
if (!lock)