1
爲什麼我的流式OpenAL源碼時間爲AL_STOPPED
狀態,迫使我致電alSourcePlay
?這通常發生在我不調用send
的速度時,即在調試模式下。當OAL源沒有足夠的隊列緩衝區時,會自動停止嗎?我如何避免這種情況?重新啓動流式OpenAL來源?
void send(audio_buffer audio) override
{
ALenum state;
alGetSourcei(source_, AL_SOURCE_STATE,&state);
if(state != AL_PLAYING)
alSourcePlay(source_); // This happens sometimes, usually when "send" is not called fast enough.
ALuint buffer = 0;
alSourceUnqueueBuffers(source_, 1, &buffer);
if(buffer)
{
alBufferData(buffer, AL_FORMAT_STEREO16, audio.data(), static_cast<ALsizei>(audio.size()*sizeof(int16_t)), 48000);
alSourceQueueBuffers(source_, 1, &buffer);
}
else
LOG << "Dropped audio.";
}