Merge branch 'master' into qt
Jeffrey Pfau jeffrey@endrift.com
Sat, 18 Oct 2014 02:24:05 -0700
2 files changed,
24 insertions(+),
11 deletions(-)
M
src/gba/gba-thread.c
→
src/gba/gba-thread.c
@@ -76,14 +76,14 @@ _waitUntilNotState(threadContext, THREAD_PAUSING);
} } -static void _changeVideoSync(struct GBAThread* threadContext, bool frameOn) { +static void _changeVideoSync(struct GBASync* sync, bool frameOn) { // Make sure the video thread can process events while the GBA thread is paused - MutexLock(&threadContext->sync.videoFrameMutex); - if (frameOn != threadContext->sync.videoFrameOn) { - threadContext->sync.videoFrameOn = frameOn; - ConditionWake(&threadContext->sync.videoFrameAvailableCond); + MutexLock(&sync->videoFrameMutex); + if (frameOn != sync->videoFrameOn) { + sync->videoFrameOn = frameOn; + ConditionWake(&sync->videoFrameAvailableCond); } - MutexUnlock(&threadContext->sync.videoFrameMutex); + MutexUnlock(&sync->videoFrameMutex); } static THREAD_ENTRY _GBAThreadRun(void* context) {@@ -434,7 +434,7 @@ frameOn = false;
} MutexUnlock(&threadContext->stateMutex); - _changeVideoSync(threadContext, frameOn); + _changeVideoSync(&threadContext->sync, frameOn); } void GBAThreadUnpause(struct GBAThread* threadContext) {@@ -446,7 +446,7 @@ ConditionWake(&threadContext->stateCond);
} MutexUnlock(&threadContext->stateMutex); - _changeVideoSync(threadContext, true); + _changeVideoSync(&threadContext->sync, true); } bool GBAThreadIsPaused(struct GBAThread* threadContext) {@@ -471,7 +471,7 @@ frameOn = false;
} MutexUnlock(&threadContext->stateMutex); - _changeVideoSync(threadContext, frameOn); + _changeVideoSync(&threadContext->sync, frameOn); } void GBAThreadPauseFromThread(struct GBAThread* threadContext) {@@ -484,7 +484,7 @@ frameOn = false;
} MutexUnlock(&threadContext->stateMutex); - _changeVideoSync(threadContext, frameOn); + _changeVideoSync(&threadContext->sync, frameOn); } #ifdef USE_PTHREADS@@ -561,7 +561,9 @@ ConditionWake(&sync->videoFrameRequiredCond);
if (!sync->videoFrameOn && !sync->videoFramePending) { return false; } - ConditionWait(&sync->videoFrameAvailableCond, &sync->videoFrameMutex); + if (sync->videoFrameOn) { + ConditionWait(&sync->videoFrameAvailableCond, &sync->videoFrameMutex); + } sync->videoFramePending = 0; sync->videoFrameSkip = frameskip; return true;@@ -577,6 +579,14 @@ }
bool GBASyncDrawingFrame(struct GBASync* sync) { return sync->videoFrameSkip <= 0; +} + +void GBASyncSuspendDrawing(struct GBASync* sync) { + _changeVideoSync(sync, false); +} + +void GBASyncResumeDrawing(struct GBASync* sync) { + _changeVideoSync(sync, true); } void GBASyncProduceAudio(struct GBASync* sync, bool wait) {
M
src/gba/gba-thread.h
→
src/gba/gba-thread.h
@@ -121,6 +121,9 @@ bool GBASyncWaitFrameStart(struct GBASync* sync, int frameskip);
void GBASyncWaitFrameEnd(struct GBASync* sync); bool GBASyncDrawingFrame(struct GBASync* sync); +void GBASyncSuspendDrawing(struct GBASync* sync); +void GBASyncResumeDrawing(struct GBASync* sync); + void GBASyncProduceAudio(struct GBASync* sync, bool wait); void GBASyncLockAudio(struct GBASync* sync); void GBASyncUnlockAudio(struct GBASync* sync);