GBA Thread: Fix possible deadlock in video sync

This commit is contained in:
Jeffrey Pfau 2015-02-17 22:20:37 -08:00
parent 1273ab4ca5
commit 848cf162af
2 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,7 @@ Bugfixes:
- 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

View File

@ -60,6 +60,11 @@ static void _waitOnInterrupt(struct GBAThread* threadContext) {
}
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 @@ static void _waitUntilNotState(struct GBAThread* threadContext, enum ThreadState
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) {