all repos — mgba @ ad2c401505b1a4e7d183201c53b0de23ab893410

mGBA Game Boy Advance Emulator

GBA Thread: Properly stop thread when video wait is enabled
Jeffrey Pfau jeffrey@endrift.com
Thu, 11 Dec 2014 04:32:51 -0800
commit

ad2c401505b1a4e7d183201c53b0de23ab893410

parent

4d7fbf37db5b55bdb1bb9c0f086a7f8ad49af5ab

1 files changed, 6 insertions(+), 5 deletions(-)

jump to
M src/gba/gba-thread.csrc/gba/gba-thread.c

@@ -363,6 +363,12 @@ MutexLock(&threadContext->sync.audioBufferMutex);

threadContext->sync.audioWait = 0; ConditionWake(&threadContext->sync.audioRequiredCond); MutexUnlock(&threadContext->sync.audioBufferMutex); + + MutexLock(&threadContext->sync.videoFrameMutex); + threadContext->sync.videoFrameWait = false; + threadContext->sync.videoFrameOn = false; + ConditionWake(&threadContext->sync.videoFrameRequiredCond); + MutexUnlock(&threadContext->sync.videoFrameMutex); } void GBAThreadReset(struct GBAThread* threadContext) {

@@ -374,11 +380,6 @@ MutexUnlock(&threadContext->stateMutex);

} void GBAThreadJoin(struct GBAThread* threadContext) { - MutexLock(&threadContext->sync.videoFrameMutex); - threadContext->sync.videoFrameWait = 0; - ConditionWake(&threadContext->sync.videoFrameRequiredCond); - MutexUnlock(&threadContext->sync.videoFrameMutex); - ThreadJoin(threadContext->thread); MutexDeinit(&threadContext->stateMutex);