all repos — mgba @ 090048ec065e5777a7f3f1c256d1a45a4b248de5

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

090048ec065e5777a7f3f1c256d1a45a4b248de5

parent

da3c45a0e775ba2806344219b3126653ce34239c

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); }