all repos — mgba @ 848cf162af61955aafb177a8ac94f2e89cd8d256

mGBA Game Boy Advance Emulator

GBA Thread: Fix possible deadlock in video sync
Jeffrey Pfau jeffrey@endrift.com
Tue, 17 Feb 2015 22:20:37 -0800
commit

848cf162af61955aafb177a8ac94f2e89cd8d256

parent

1273ab4ca50329bf833f7a5ca2ab823692dacb98

2 files changed, 10 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -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.csrc/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) {