Audio: Fix data race when a device is used from multiple threads
OpenAL devices can be used from multiple threads and the error handling code (inspired by OpenGLRenderer) did not take that into account. This is not a problem for the OpenGLRenderer since contexts are thread-local which is not the case for OpenAL devices.
This commit is contained in:
@@ -178,12 +178,8 @@ namespace Nz
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
assert(s_currentALDevice == this);
|
||||
|
||||
alGetError();
|
||||
|
||||
m_didCollectErrors = false;
|
||||
m_hadAnyError = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -196,7 +192,7 @@ namespace Nz
|
||||
ALuint bufferId = 0;
|
||||
alGenBuffers(1, &bufferId);
|
||||
|
||||
if (!DidLastCallSucceed())
|
||||
if (!ProcessErrorFlag())
|
||||
{
|
||||
NazaraError("failed to create OpenAL buffer");
|
||||
return {};
|
||||
@@ -214,7 +210,7 @@ namespace Nz
|
||||
ALuint sourceId = 0;
|
||||
alGenSources(1, &sourceId);
|
||||
|
||||
if (!DidLastCallSucceed())
|
||||
if (!ProcessErrorFlag())
|
||||
{
|
||||
NazaraError("failed to create OpenAL buffer");
|
||||
return {};
|
||||
@@ -365,7 +361,6 @@ namespace Nz
|
||||
assert(s_currentALDevice == this);
|
||||
|
||||
bool hasAnyError = false;
|
||||
|
||||
if (ALuint lastError = alGetError(); lastError != AL_NO_ERROR)
|
||||
{
|
||||
hasAnyError = true;
|
||||
@@ -373,9 +368,6 @@ namespace Nz
|
||||
NazaraErrorFmt("OpenAL error: {0}", TranslateOpenALError(lastError));
|
||||
}
|
||||
|
||||
m_didCollectErrors = true;
|
||||
m_hadAnyError = hasAnyError;
|
||||
|
||||
return hasAnyError;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user