all repos — mgba @ 2f9bcf63b73e3edfd80a572981c3885bb30a09b9

mGBA Game Boy Advance Emulator

Clean up audio sync code
Jeffrey Pfau jeffrey@endrift.com
Tue, 08 Oct 2013 22:36:55 -0700
commit

2f9bcf63b73e3edfd80a572981c3885bb30a09b9

parent

84ad94b85e5c6fc8a0c1cd5c0dfca9809d2aeca7

3 files changed, 3 insertions(+), 5 deletions(-)

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

@@ -178,6 +178,9 @@ }

pthread_mutex_lock(&audio->bufferMutex); while (CircleBufferSize(&audio->left) + (GBA_AUDIO_SAMPLES * 2 / 5) >= audio->left.capacity) { + if (!audio->p->sync->audioWait) { + break; + } GBASyncProduceAudio(audio->p->sync, &audio->bufferMutex); } CircleBufferWrite32(&audio->left, sampleLeft);
M src/gba/gba-thread.csrc/gba/gba-thread.c

@@ -92,7 +92,6 @@

pthread_mutex_init(&threadContext->sync.videoFrameMutex, 0); pthread_cond_init(&threadContext->sync.videoFrameAvailableCond, 0); pthread_cond_init(&threadContext->sync.videoFrameRequiredCond, 0); - pthread_cond_init(&threadContext->sync.audioAvailableCond, 0); pthread_cond_init(&threadContext->sync.audioRequiredCond, 0); pthread_mutex_lock(&threadContext->startMutex);

@@ -122,8 +121,6 @@ pthread_cond_destroy(&threadContext->sync.videoFrameAvailableCond);

pthread_cond_broadcast(&threadContext->sync.videoFrameRequiredCond); pthread_cond_destroy(&threadContext->sync.videoFrameRequiredCond); - pthread_cond_broadcast(&threadContext->sync.audioAvailableCond); - pthread_cond_destroy(&threadContext->sync.audioAvailableCond); pthread_cond_broadcast(&threadContext->sync.audioRequiredCond); pthread_cond_destroy(&threadContext->sync.audioRequiredCond); }

@@ -172,7 +169,6 @@ return sync->videoFrameSkip <= 0;

} void GBASyncProduceAudio(struct GBASync* sync, pthread_mutex_t* mutex) { - pthread_cond_broadcast(&sync->audioAvailableCond); if (&sync->audioWait) { pthread_cond_wait(&sync->audioRequiredCond, mutex); }
M src/gba/gba-thread.hsrc/gba/gba-thread.h

@@ -32,7 +32,6 @@ pthread_cond_t videoFrameAvailableCond;

pthread_cond_t videoFrameRequiredCond; int audioWait; - pthread_cond_t audioAvailableCond; pthread_cond_t audioRequiredCond; } sync; };