From: fgsfds Date: Mon, 2 Sep 2019 17:41:31 +0000 (+0300) Subject: Sound: OpenAL: Reclaim stream buffers on stream change X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=48876eaffb8944a53bf1fd5320a4c00493a468e5;p=d2df-sdl.git Sound: OpenAL: Reclaim stream buffers on stream change --- diff --git a/src/engine/e_sound_al.inc b/src/engine/e_sound_al.inc index a5c8364..b73b37f 100644 --- a/src/engine/e_sound_al.inc +++ b/src/engine/e_sound_al.inc @@ -451,6 +451,8 @@ begin end; procedure AssignSound(ID: DWORD; Src: ALuint); inline; +var + S: ALint; begin alGetError(); // reset error state @@ -459,8 +461,17 @@ begin // this is a stream // reset position e_SoundsArray[ID].Loader.SetPosition(0); - if CurStream <> ID then // changing streams, stop the thing just in case - alSourceStop(Src); + if CurStream <> ID then // changing streams + begin + alSourceStop(Src); // this should mark all buffers as processed + alGetSourcei(Src, AL_BUFFERS_PROCESSED, S); + // unqueue all buffers + if S > 0 then + begin + alSourceUnqueueBuffers(Src, S, @alStreamBufs[alStreamAvail]); + alStreamAvail := NUM_STREAM_BUFFERS; + end; + end; // this shit is playing now CurStream := ID; end