Use alSourceQueueBuffers()
to queue up buffers to be played in direct succession by a source. During playback, use alGetSourcei()
in conjunction with AL_BUFFERS_PROCESSED
to obtain the number of buffers that have been fully played and are ready for reuse. alSourceUnqueueBuffers()
will pop these buffers off the queue for you, so you can fill them with new data and queue them up again.
Basically you will be looping in a thread: sleeping for a short time, testing for new usable buffers, filling them with data, queuing them up and going to sleep again.
SFML implements this in its SoundStream class (C++), you can look at it as a reference if you like.