GBA Thread: Handle the lack of a sync object properly
Jeffrey Pfau jeffrey@endrift.com
Tue, 09 Dec 2014 12:58:35 -0800
1 files changed,
28 insertions(+),
0 deletions(-)
jump to
M
src/gba/gba-thread.c
→
src/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); }