Advertisement

OpenAL Ring Buffer of Buffers Into Source

Started by May 13, 2023 06:00 PM
1 comment, last by L. Spiro 1 year, 7 months ago

I have a ring buffer of OpenAL buffers (::alGenBuffers()) that are meant to be queued into a single source (::alGenSources()::alSourceQueueBuffers()). The ring buffer has room for 4, 40, 400—whatever number of buffers I want. Each time a buffer is filled to be queued into the source, first I check ::alGetSourcei( AL_BUFFERS_PROCESSED ) and unqueue past buffers that have been processed (::alSourceUnqueueBuffers()).

In concept there should be nothing wrong with this approach; I am adding samples and queuing new buffers at the same pace as they are being played, which means by the time I have gone through the ring buffer and am ready to start reusing buffers, those buffers are guaranteed to have already finished playing.

The first few passes through the ring buffer this works, but often it doesn’t. AL_BUFFERS_PROCESSED simply returns 0 even though it definitely has finished playing some of the buffers and they should be unqueable. Debugging has shown that this isn’t a logic error in my implementation, nor is there bad pacing when it comes to how often I try to push new buffers etc. There has to be something I am doing wrong with OpenAL.

Are there any gotcha’s I should take care to handle in a system like this?


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Oh.

I got it.

I was playing the source after each buffer upload. That’s a gotcha. Only play the source if it is not currently playing.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Advertisement

Video Converter Online is a great tool for anyone who needs to convert video files from one format to convert files. It's fast, easy to use, and supports a wide range of video file types. Plus, it's available online so you can access it from anywhere.

This topic is closed to new replies.

Advertisement