Bink: simplify AL buffer reclamation code
This commit is contained in:
parent
2bc7bac0f3
commit
1fa524ff67
1 changed files with 8 additions and 16 deletions
22
src/bink.c
22
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);
|
||||
int processed = 0;
|
||||
alGetSourcei(aMovie->alSource, AL_BUFFERS_PROCESSED, &processed);
|
||||
if (processed > 0) {
|
||||
ALuint buffers[FRAMEQUEUESIZE];
|
||||
alSourceUnqueueBuffers(aMovie->alSource, processed, buffers);
|
||||
AL_CHECK();
|
||||
|
||||
if (buffer > 0) {
|
||||
aMovie->alFreeBuffers[aMovie->alNumFreeBuffers] = buffer;
|
||||
aMovie->alNumFreeBuffers++;
|
||||
}
|
||||
processedBuffers--;
|
||||
}
|
||||
alSourcePlay(aMovie->alSource);
|
||||
for (int i = 0; i < processed; i++)
|
||||
aMovie->alFreeBuffers[aMovie->alNumFreeBuffers++] = buffers[i];
|
||||
}
|
||||
|
||||
// queue this frame
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue