diff options
| author | Timotej Lazar <timotej.lazar@araneo.si> | 2020-05-31 12:37:55 +0200 |
|---|---|---|
| committer | Timotej Lazar <timotej.lazar@araneo.si> | 2020-05-31 12:37:55 +0200 |
| commit | 1fa524ff67f44ea6736c72492ea6b84e45e6c907 (patch) | |
| tree | bfad3a2c692078c13e316975b0ce22f1277b9ea3 /src | |
| parent | 2bc7bac0f34e78f1e7bd2fdfbb9caa2d90b57887 (diff) | |
Bink: simplify AL buffer reclamation code
Diffstat (limited to 'src')
| -rw-r--r-- | src/bink.c | 24 |
1 files changed, 8 insertions, 16 deletions
@@ -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 |
