Skip to content

Commit

Permalink
Remove thread pause/resume to fix manual save states
Browse files Browse the repository at this point in the history
  • Loading branch information
clobber committed Sep 23, 2018
1 parent 2604631 commit 37ae2ac
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions PPSSPPGameCore.mm
Original file line number Diff line number Diff line change
Expand Up @@ -274,26 +274,28 @@ - (NSUInteger)length
static void _OESaveStateCallback(bool status, std::string message, void *cbUserData)
{
void (^block)(BOOL, NSError *) = (__bridge_transfer void(^)(BOOL, NSError *))cbUserData;


block(status, nil);
}

static void _OELoadStateCallback(bool status, std::string message, void *cbUserData)
{
void (^block)(BOOL, NSError *) = (__bridge_transfer void(^)(BOOL, NSError *))cbUserData;

//Unpause the EmuThread by requesting it to start again
NativeSetThreadState(OpenEmuCoreThread::EmuThreadState::START_REQUESTED);

block(status, nil);
}

- (void)saveStateToFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block
{
SaveState::Save(fileName.fileSystemRepresentation, _OESaveStateCallback, (__bridge_retained void *)[block copy]);
if(_isInitialized)
//We need to pause our EmuThread so we don't try to process the save state in the middle of a Frame Render
NativeSetThreadState(OpenEmuCoreThread::EmuThreadState::PAUSE_REQUESTED);

SaveState::Process();
}

- (void)loadStateFromFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block
{
SaveState::Load(fileName.fileSystemRepresentation, _OESaveStateCallback, (__bridge_retained void *)[block copy]);
SaveState::Load(fileName.fileSystemRepresentation, _OELoadStateCallback, (__bridge_retained void *)[block copy]);
if(_isInitialized){
//We need to pause our EmuThread so we don't try to process the save state in the middle of a Frame Render
NativeSetThreadState(OpenEmuCoreThread::EmuThreadState::PAUSE_REQUESTED);
Expand Down

0 comments on commit 37ae2ac

Please sign in to comment.