How do I stream audio into OpenAL Sources?

醉酒当歌 提交于 2019-12-06 05:22:24

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!