Quick answer: If a streaming source runs out of queued buffers, it transitions to AL_STOPPED. After re-queueing, check the state and call alSourcePlay again.
A music streamer queues decoded buffers to an OpenAL source. After a hitch (slow decode), the music goes silent permanently — the source starved and stopped.
The Starvation Bug
OpenAL plays queued buffers in order. If all processed buffers are unqueued and no new ones arrive in time, the source plays through everything and enters AL_STOPPED. Queueing more buffers afterward doesn’t auto-resume.
Recovery Pattern
// streaming update, called regularly
int processed;
alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
while (processed-- > 0) {
ALuint buf;
alSourceUnqueueBuffers(source, 1, &buf);
FillBuffer(buf);
alSourceQueueBuffers(source, 1, &buf);
}
// CRITICAL: recover from starvation
ALint state;
alGetSourcei(source, AL_SOURCE_STATE, &state);
if (state != AL_PLAYING) {
alSourcePlay(source);
}
Every update, check the state. If it’s not AL_PLAYING but should be, re-play.
Prevent Starvation
- Use enough buffers (4–8) so a hitch doesn’t drain them.
- Decode on a background thread so the audio thread never waits.
- Use larger buffers (more ms per buffer) for more headroom.
Verifying
Force a decode hitch (sleep the decoder briefly). Music skips but recovers and continues. No permanent silence.
“A starved OpenAL source stops for good. Always re-check state and re-play after queueing.”
Higher-level libraries (FMOD, miniaudio, SoLoud) handle streaming starvation for you — worth adopting if you don’t need raw OpenAL control.