summaryrefslogtreecommitdiff
path: root/src/bink.c
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.si>2020-05-31 12:37:55 +0200
committerTimotej Lazar <timotej.lazar@araneo.si>2020-05-31 12:37:55 +0200
commit1fa524ff67f44ea6736c72492ea6b84e45e6c907 (patch)
treebfad3a2c692078c13e316975b0ce22f1277b9ea3 /src/bink.c
parent2bc7bac0f34e78f1e7bd2fdfbb9caa2d90b57887 (diff)
Bink: simplify AL buffer reclamation code
Diffstat (limited to 'src/bink.c')
-rw-r--r--src/bink.c24
1 files 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