GBA Thread: Fix possible deadlock in video sync
Jeffrey Pfau jeffrey@endrift.com
Tue, 17 Feb 2015 22:20:37 -0800
2 files changed,
10 insertions(+),
0 deletions(-)
M
CHANGES
→
CHANGES
@@ -37,6 +37,7 @@ - SDL: Properly clean up if a game doesn't launch
- Debugger: Disassembly now lists PSR bitmasks (fixes #191) - GBA BIOS: Prevent CpuSet and CpuFastSet from using BIOS addresses as a source (fixes #184) - GBA RR: Fix fallthrough error when reading tags from a movie + - GBA Thread: Fix possible deadlock in video sync Misc: - GBA Audio: Change internal audio sample buffer from 32-bit to 16-bit samples - GBA Memory: Simplify memory API and use fixed bus width
M
src/gba/supervisor/thread.c
→
src/gba/supervisor/thread.c
@@ -60,6 +60,11 @@ }
} static void _waitUntilNotState(struct GBAThread* threadContext, enum ThreadState oldState) { + MutexLock(&threadContext->sync.videoFrameMutex); + bool videoFrameWait = threadContext->sync.videoFrameWait; + threadContext->sync.videoFrameWait = false; + MutexUnlock(&threadContext->sync.videoFrameMutex); + while (threadContext->state == oldState) { MutexUnlock(&threadContext->stateMutex);@@ -74,6 +79,10 @@
MutexLock(&threadContext->stateMutex); ConditionWake(&threadContext->stateCond); } + + MutexLock(&threadContext->sync.videoFrameMutex); + threadContext->sync.videoFrameWait = videoFrameWait; + MutexUnlock(&threadContext->sync.videoFrameMutex); } static void _pauseThread(struct GBAThread* threadContext, bool onThread) {