all repos — mgba @ 0d1b323e224d5be9a20df47ad37752bb94843acf

mGBA Game Boy Advance Emulator

Fix edge case with video-frame sync where it may never wake up the display thread
Jeffrey Pfau jeffrey@endrift.com
Wed, 15 Oct 2014 04:51:19 -0700
commit

0d1b323e224d5be9a20df47ad37752bb94843acf

parent

70f94db208293a100b46bda90d6c9b6f720de6c1

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

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

@@ -520,10 +520,12 @@ MutexLock(&sync->videoFrameMutex);

++sync->videoFramePending; --sync->videoFrameSkip; if (sync->videoFrameSkip < 0) { - ConditionWake(&sync->videoFrameAvailableCond); - while (sync->videoFrameWait && sync->videoFramePending) { - ConditionWait(&sync->videoFrameRequiredCond, &sync->videoFrameMutex); - } + do { + ConditionWake(&sync->videoFrameAvailableCond); + if (sync->videoFrameWait) { + ConditionWait(&sync->videoFrameRequiredCond, &sync->videoFrameMutex); + } + } while (sync->videoFrameWait && sync->videoFramePending); } MutexUnlock(&sync->videoFrameMutex);