From 52f8f511337e3c1e0d4ee0a887b0169e226e4836 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 11 Dec 2014 04:32:51 -0800 Subject: [PATCH] GBA Thread: Properly stop thread when video wait is enabled --- src/gba/gba-thread.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gba/gba-thread.c b/src/gba/gba-thread.c index 564fa77ba..ecab5294f 100644 --- a/src/gba/gba-thread.c +++ b/src/gba/gba-thread.c @@ -360,6 +360,12 @@ void GBAThreadEnd(struct GBAThread* threadContext) { 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) { @@ -371,11 +377,6 @@ void GBAThreadReset(struct GBAThread* threadContext) { } 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);