Sign in to follow this  

OpenAL sourceQueue problem

Recommended Posts

I've got a strange problem with OpenAL Sources. The way my program is organized: StartPlaying(); Fill two buffers and queue them to a source. Update(); Get the number of Buffers processed and unqueue every processed Buffer. If there is still data left to stream, stream it and re-queue the buffer. If not, just unqueue the buffer. Now the problem: If there's no data left to stream, the next buffer is empty, and the overnext buffer is filled with the audio information of the second buffer, don't know why. Here what happens to the buffers: Buffer1 gets filled Buffer2 gets filled Buffer1 playing Buffer1 finished playing Buffer2 starts playing Update(); tries to fill Buffer1, but there's no data left, so it won't be filled and just unqueued Buffer2 finished playing NOW: I don't know what's happening... I thought it would just give up playing the source, because there aren't any queued buffers left. Can you help me ?

Share this post

Link to post
Share on other sites
Query the source using alSourcei() for more information about what is happening. Try doing this when the source is supposed to be stopped. Make sure the source isn't looping. Did you unqueue Buffer 2 when it was finished?
You can also take a look at some code that demostrates buffer queueing here.

Welcome to

Share this post

Link to post
Share on other sites
I unqueue a buffer, if alSourcei(mysource, AL_BUFFERS_PROCESSED, &processed); returns at least 1 in processed. If there's no data left to stream, it just unqueues the buffer without queueing a new one.
Even stranger:
I outputted how many buffers are in the queue with alSourcei(mysource, AL_BUFFERS_QUEUED, &queued);. After it tries to update the source, when there's no data left to stream, it's 1 (what is correct, because buffer1 is still playing). And the next time it's 0, but it doesn't stop playing.
The source is not looping.
Thanks for the example :)

I've solved the problem with

char data = 0;
alBufferData(bufferid, theformat, &data, 1, therate);

It's called when there isn't any data left for buffer with the Buffer ID bufferid.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this