summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-10-26 19:13:50 +0100
committerSergeanur <s.anureev@yandex.ua>2020-10-26 19:13:50 +0100
commitd94b36c20261851105e0745134b1fb7f2b6558aa (patch)
tree065a0007f9e9c44febd8081499c04037fcf579f0
parentAdd option to enable asan (diff)
downloadre3-d94b36c20261851105e0745134b1fb7f2b6558aa.tar
re3-d94b36c20261851105e0745134b1fb7f2b6558aa.tar.gz
re3-d94b36c20261851105e0745134b1fb7f2b6558aa.tar.bz2
re3-d94b36c20261851105e0745134b1fb7f2b6558aa.tar.lz
re3-d94b36c20261851105e0745134b1fb7f2b6558aa.tar.xz
re3-d94b36c20261851105e0745134b1fb7f2b6558aa.tar.zst
re3-d94b36c20261851105e0745134b1fb7f2b6558aa.zip
-rw-r--r--src/audio/sampman_oal.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index 720849f8..ad6961b0 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -109,9 +109,9 @@ ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS];
struct
{
ALuint buffer;
- ALuint timer;
+ ALint timer;
- bool IsEmpty() { return timer == 0; }
+ bool IsEmpty() { return buffer == 0; }
void Set(ALuint buf) { buffer = buf; }
void Wait() { timer = 10000; }
void Init()
@@ -121,19 +121,32 @@ struct
}
void Term()
{
- if ( buffer != 0 && alIsBuffer(buffer) )
+ if (buffer != 0 && alIsBuffer(buffer)) {
alDeleteBuffers(1, &buffer);
+ assert(alGetError() == AL_NO_ERROR);
+ }
timer = 0;
+ buffer = 0;
}
void Update()
{
if ( !(timer > 0) ) return;
- timer -= ALuint(CTimer::GetTimeStepInMilliseconds());
+ timer -= ALint(CTimer::GetTimeStepInMilliseconds());
if ( timer > 0 ) return;
- if ( buffer != 0 && alIsBuffer(buffer) )
+ timer = 0;
+ if ( buffer != 0 )
{
+ if (!alIsBuffer(buffer))
+ {
+ buffer = 0;
+ return;
+ }
alDeleteBuffers(1, &buffer);
- timer = ( alGetError() == AL_NO_ERROR ) ? 0 : 10000;
+ ALenum error = alGetError();
+ if (error != AL_NO_ERROR)
+ timer = 10000;
+ else
+ buffer = 0;
}
}
}ALBuffers[SAMPLEBANK_MAX];