mirror of https://github.com/mgba-emu/mgba.git
Clean up audio sync code
This commit is contained in:
parent
84ad94b85e
commit
2f9bcf63b7
|
@ -178,6 +178,9 @@ static void _sample(struct GBAAudio* audio) {
|
|||
|
||||
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);
|
||||
|
|
|
@ -92,7 +92,6 @@ int GBAThreadStart(struct GBAThread* threadContext) {
|
|||
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 @@ void GBAThreadJoin(struct GBAThread* threadContext) {
|
|||
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 @@ int GBASyncDrawingFrame(struct GBASync* sync) {
|
|||
}
|
||||
|
||||
void GBASyncProduceAudio(struct GBASync* sync, pthread_mutex_t* mutex) {
|
||||
pthread_cond_broadcast(&sync->audioAvailableCond);
|
||||
if (&sync->audioWait) {
|
||||
pthread_cond_wait(&sync->audioRequiredCond, mutex);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ struct GBAThread {
|
|||
pthread_cond_t videoFrameRequiredCond;
|
||||
|
||||
int audioWait;
|
||||
pthread_cond_t audioAvailableCond;
|
||||
pthread_cond_t audioRequiredCond;
|
||||
} sync;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue