Audio: Fix compilation on emscripten | unity_build
This commit is contained in:
parent
3fb1096d07
commit
5253a80a24
|
|
@ -25,7 +25,10 @@ namespace Nz
|
||||||
|
|
||||||
// Regular OpenAL contexts are process-wide, but ALC_EXT_thread_local_context allows thread-local contexts
|
// Regular OpenAL contexts are process-wide, but ALC_EXT_thread_local_context allows thread-local contexts
|
||||||
const OpenALDevice* s_currentGlobalALDevice;
|
const OpenALDevice* s_currentGlobalALDevice;
|
||||||
|
|
||||||
|
#ifdef ALC_EXT_thread_local_context
|
||||||
thread_local const OpenALDevice* s_currentThreadALDevice;
|
thread_local const OpenALDevice* s_currentThreadALDevice;
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename FuncType, std::size_t FuncIndex, typename>
|
template<typename FuncType, std::size_t FuncIndex, typename>
|
||||||
struct ALWrapper;
|
struct ALWrapper;
|
||||||
|
|
@ -175,8 +178,10 @@ namespace Nz
|
||||||
alcDestroyContext(m_context);
|
alcDestroyContext(m_context);
|
||||||
alcCloseDevice(m_device);
|
alcCloseDevice(m_device);
|
||||||
|
|
||||||
|
#ifdef ALC_EXT_thread_local_context
|
||||||
if (s_currentThreadALDevice)
|
if (s_currentThreadALDevice)
|
||||||
s_currentThreadALDevice = nullptr;
|
s_currentThreadALDevice = nullptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (s_currentGlobalALDevice == this)
|
if (s_currentGlobalALDevice == this)
|
||||||
s_currentGlobalALDevice = nullptr;
|
s_currentGlobalALDevice = nullptr;
|
||||||
|
|
@ -331,6 +336,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||||
|
|
||||||
|
#ifdef ALC_EXT_thread_local_context
|
||||||
if (alcSetThreadContext)
|
if (alcSetThreadContext)
|
||||||
{
|
{
|
||||||
if (s_currentThreadALDevice != this)
|
if (s_currentThreadALDevice != this)
|
||||||
|
|
@ -340,17 +346,21 @@ namespace Nz
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (s_currentGlobalALDevice != this)
|
if (s_currentGlobalALDevice != this)
|
||||||
{
|
{
|
||||||
|
alcMakeContextCurrent(m_context);
|
||||||
|
s_currentGlobalALDevice = this;
|
||||||
|
|
||||||
|
#ifdef ALC_EXT_thread_local_context
|
||||||
/*
|
/*
|
||||||
From EXT_thread_local_context:
|
From EXT_thread_local_context:
|
||||||
alcMakeContextCurrent changes the current process-wide context and set the current thread-local context to NULL.
|
alcMakeContextCurrent changes the current process-wide context and set the current thread-local context to NULL.
|
||||||
This has the side effect of changing the current thread-local context, so that the new current process-wide context will be used.
|
This has the side effect of changing the current thread-local context, so that the new current process-wide context will be used.
|
||||||
*/
|
*/
|
||||||
alcMakeContextCurrent(m_context);
|
|
||||||
s_currentGlobalALDevice = this;
|
|
||||||
s_currentThreadALDevice = nullptr;
|
s_currentThreadALDevice = nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -514,9 +524,13 @@ namespace Nz
|
||||||
|
|
||||||
const OpenALDevice* OpenALDevice::GetCurrentDevice()
|
const OpenALDevice* OpenALDevice::GetCurrentDevice()
|
||||||
{
|
{
|
||||||
|
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||||
|
|
||||||
|
#ifdef ALC_EXT_thread_local_context
|
||||||
const OpenALDevice* device = s_currentThreadALDevice;
|
const OpenALDevice* device = s_currentThreadALDevice;
|
||||||
if (device)
|
if (device)
|
||||||
return device;
|
return device;
|
||||||
|
#endif
|
||||||
|
|
||||||
return s_currentGlobalALDevice;
|
return s_currentGlobalALDevice;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue