tags:

views:

8

answers:

0

I'm doing iOS development and trying to reuse a stopped OpenAL streaming source for another streaming sound, but sometimes the source is showing AL_BUFFERS_PROCESSED remaining even after it's been stopped and cleared.

I'm using the following code:

alSourceStop(source_id);
alSourcei(source_id, AL_BUFFER, AL_NONE);

ALint buffers_processed = 0;
alGetSourcei(source_id, AL_BUFFERS_PROCESSED, &buffers_processed);
NSLog(@"stopSound: stopped a source with %d buffers processed",buffers_processed);
while(buffers_processed > 0)
{
   ALuint unqueued_buffer;
   alSourceUnqueueBuffers(source_id, 1, &unqueued_buffer);
   buffers_processed--;
}
buffers_processed = 0;
alGetSourcei(source_id, AL_BUFFERS_PROCESSED, &buffers_processed);
NSLog(@"stopSound: after purge attempt, source has %d buffers processed",buffers_processed);

Most of the time, I'm getting NSLog saying "0 buffers processed", but occasionally it comes back with:
stopSound: stopped a source with 32 buffers processed
stopSound: after purge attempt, source has 32 buffers processed
Shouldn't this always be 0 after a call to alSourcei(source_id, AL_BUFFER, AL_NONE)?

Anyone know what I'm missing here? Thanks for any help.

Brad