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