all repos — mgba @ 7edf934a59ef29ad76e23aa935cdef8557a178b2

mGBA Game Boy Advance Emulator

GBA Thread: Handle the lack of a sync object properly
Jeffrey Pfau jeffrey@endrift.com
Tue, 09 Dec 2014 12:58:35 -0800
commit

7edf934a59ef29ad76e23aa935cdef8557a178b2

parent

53023441da38f60ddfc8f1f02a8b5360025e56ae

1 files changed, 28 insertions(+), 0 deletions(-)

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

@@ -628,18 +628,34 @@ MutexUnlock(&sync->videoFrameMutex);

} bool GBASyncDrawingFrame(struct GBASync* sync) { + if (!sync) { + return true; + } + return sync->videoFrameSkip <= 0; } void GBASyncSuspendDrawing(struct GBASync* sync) { + if (!sync) { + return; + } + _changeVideoSync(sync, false); } void GBASyncResumeDrawing(struct GBASync* sync) { + if (!sync) { + return; + } + _changeVideoSync(sync, true); } void GBASyncProduceAudio(struct GBASync* sync, bool wait) { + if (!sync) { + return; + } + if (sync->audioWait && wait) { // TODO loop properly in event of spurious wakeups ConditionWait(&sync->audioRequiredCond, &sync->audioBufferMutex);

@@ -648,14 +664,26 @@ MutexUnlock(&sync->audioBufferMutex);

} void GBASyncLockAudio(struct GBASync* sync) { + if (!sync) { + return; + } + MutexLock(&sync->audioBufferMutex); } void GBASyncUnlockAudio(struct GBASync* sync) { + if (!sync) { + return; + } + MutexUnlock(&sync->audioBufferMutex); } void GBASyncConsumeAudio(struct GBASync* sync) { + if (!sync) { + return; + } + ConditionWake(&sync->audioRequiredCond); MutexUnlock(&sync->audioBufferMutex); }