From 1fa524ff67f44ea6736c72492ea6b84e45e6c907 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 31 May 2020 12:37:55 +0200 Subject: [PATCH] Bink: simplify AL buffer reclamation code --- src/bink.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/bink.c b/src/bink.c index eba59e3..4ac188c 100644 --- a/src/bink.c +++ b/src/bink.c @@ -174,22 +174,14 @@ static int DecodeAudioFrame(struct binkMovie* aMovie) return 0; // reclaim completed frames - int processedBuffers = 0; - alGetSourcei(aMovie->alSource, AL_BUFFERS_PROCESSED, &processedBuffers); - if (processedBuffers > 0) { - alSourceStop(aMovie->alSource); - while (processedBuffers > 0) { - ALuint buffer = 0; - alSourceUnqueueBuffers(aMovie->alSource, 1, &buffer); - AL_CHECK(); - - if (buffer > 0) { - aMovie->alFreeBuffers[aMovie->alNumFreeBuffers] = buffer; - aMovie->alNumFreeBuffers++; - } - processedBuffers--; - } - alSourcePlay(aMovie->alSource); + int processed = 0; + alGetSourcei(aMovie->alSource, AL_BUFFERS_PROCESSED, &processed); + if (processed > 0) { + ALuint buffers[FRAMEQUEUESIZE]; + alSourceUnqueueBuffers(aMovie->alSource, processed, buffers); + AL_CHECK(); + for (int i = 0; i < processed; i++) + aMovie->alFreeBuffers[aMovie->alNumFreeBuffers++] = buffers[i]; } // queue this frame