From 242dc5067b2b06ed5197781971dec12661eec7aa Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 22 Apr 2015 20:41:54 -0700 Subject: [PATCH] GBA: Fix hang when loading a savestate if sync to video is enabled --- CHANGES | 1 + src/gba/serialize.c | 2 +- src/gba/supervisor/thread.c | 10 ++++++++++ src/gba/supervisor/thread.h | 1 + 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 3feb26d4f..6d0f3e1bf 100644 --- a/CHANGES +++ b/CHANGES @@ -33,6 +33,7 @@ Bugfixes: - GBA Memory: Fix 32-bit loads from unaddress cartridge space - Qt: Fix multiplayer windows opening as the wrong size - Qt: Fix controllers sometimes not loading the right profile + - GBA: Fix hang when loading a savestate if sync to video is enabled Misc: - Qt: Show multiplayer numbers in window title - Qt: Handle saving input settings better diff --git a/src/gba/serialize.c b/src/gba/serialize.c index f6574d64c..9412d7ac0 100644 --- a/src/gba/serialize.c +++ b/src/gba/serialize.c @@ -178,7 +178,7 @@ static bool _loadPNGState(struct GBA* gba, struct VFile* vf) { PNGReadFooter(png, end); PNGReadClose(png, info, end); gba->video.renderer->putPixels(gba->video.renderer, VIDEO_HORIZONTAL_PIXELS, pixels); - GBASyncPostFrame(gba->sync); + GBASyncForceFrame(gba->sync); free(pixels); return true; diff --git a/src/gba/supervisor/thread.c b/src/gba/supervisor/thread.c index a436c522b..98a207fd8 100644 --- a/src/gba/supervisor/thread.c +++ b/src/gba/supervisor/thread.c @@ -712,6 +712,16 @@ void GBASyncPostFrame(struct GBASync* sync) { MutexUnlock(&sync->videoFrameMutex); } +void GBASyncForceFrame(struct GBASync* sync) { + if (!sync) { + return; + } + + MutexLock(&sync->videoFrameMutex); + ConditionWake(&sync->videoFrameAvailableCond); + MutexUnlock(&sync->videoFrameMutex); +} + bool GBASyncWaitFrameStart(struct GBASync* sync, int frameskip) { if (!sync) { return true; diff --git a/src/gba/supervisor/thread.h b/src/gba/supervisor/thread.h index ab98610e5..933cf2830 100644 --- a/src/gba/supervisor/thread.h +++ b/src/gba/supervisor/thread.h @@ -138,6 +138,7 @@ void GBAThreadTakeScreenshot(struct GBAThread* threadContext); #endif void GBASyncPostFrame(struct GBASync* sync); +void GBASyncForceFrame(struct GBASync* sync); bool GBASyncWaitFrameStart(struct GBASync* sync, int frameskip); void GBASyncWaitFrameEnd(struct GBASync* sync); bool GBASyncDrawingFrame(struct GBASync* sync);