Fix raw samples playback with newer openal-soft versions.

Newer openal-soft versions changed the way how the processed buffers are
counted when in AL_STOPPED state. Previously only processed buffers were
counted, now all buffers are. Change our unqueue logic to match this new
behavior.

This was debugged and fixed @xorw, I'm just committing the patch. This
closes issue #185.
This commit is contained in:
Yamagi Burmeister 2017-04-22 09:42:56 +02:00
parent 9bc980811f
commit 12fba237c2

View file

@ -90,25 +90,28 @@ AL_StreamUpdate(void)
int numBuffers; int numBuffers;
ALint state; ALint state;
/* Un-queue any buffers, and delete them */
qalGetSourcei(streamSource, AL_BUFFERS_PROCESSED, &numBuffers);
while (numBuffers--)
{
ALuint buffer;
qalSourceUnqueueBuffers(streamSource, 1, &buffer);
qalDeleteBuffers(1, &buffer);
active_buffers--;
}
/* Start the streamSource playing if necessary */
qalGetSourcei(streamSource, AL_BUFFERS_QUEUED, &numBuffers);
qalGetSourcei(streamSource, AL_SOURCE_STATE, &state); qalGetSourcei(streamSource, AL_SOURCE_STATE, &state);
if (state == AL_STOPPED) if (state == AL_STOPPED)
{ {
streamPlaying = false; streamPlaying = false;
} }
else
{
/* Un-queue any already pleyed buffers and delete them */
qalGetSourcei(streamSource, AL_BUFFERS_PROCESSED, &numBuffers);
while (numBuffers--)
{
ALuint buffer;
qalSourceUnqueueBuffers(streamSource, 1, &buffer);
qalDeleteBuffers(1, &buffer);
active_buffers--;
}
}
/* Start the streamSource playing if necessary */
qalGetSourcei(streamSource, AL_BUFFERS_QUEUED, &numBuffers);
if (!streamPlaying && numBuffers) if (!streamPlaying && numBuffers)
{ {
@ -665,7 +668,7 @@ AL_Update(void)
AL_StreamUpdate(); AL_StreamUpdate();
AL_IssuePlaysounds(); AL_IssuePlaysounds();
oal_update_underwater(); oal_update_underwater();
} }
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */