From 12fba237c2441b7ab7e42c94b50d88ad1a91d222 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sat, 22 Apr 2017 09:42:56 +0200 Subject: [PATCH] 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. --- src/client/sound/openal.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/client/sound/openal.c b/src/client/sound/openal.c index 6615c79a..e8f5fb8d 100644 --- a/src/client/sound/openal.c +++ b/src/client/sound/openal.c @@ -90,25 +90,28 @@ AL_StreamUpdate(void) int numBuffers; 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); if (state == AL_STOPPED) { 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) { @@ -665,7 +668,7 @@ AL_Update(void) AL_StreamUpdate(); AL_IssuePlaysounds(); - oal_update_underwater(); + oal_update_underwater(); } /* ----------------------------------------------------------------- */