Audio: Implement support for ALC_EXT_thread_local_context

This commit is contained in:
SirLynix
2023-12-04 17:38:05 +01:00
parent 3e1b61070c
commit 3fb1096d07
3 changed files with 74 additions and 14 deletions

View File

@@ -27,6 +27,7 @@ namespace Nz
enum class OpenALExtension
{
SourceLatency,
ThreadLocalContext,
Max = SourceLatency
};
@@ -82,6 +83,8 @@ namespace Nz
OpenALDevice& operator=(const OpenALDevice&) = delete;
OpenALDevice& operator=(OpenALDevice&&) = delete;
static const OpenALDevice* GetCurrentDevice();
// We give each device its own set of function pointer, even though regular OpenAL extensions are always the same (for a set library).
// This makes it easier to wrap them (for error handling), and extension pointers are device-local anyway.
#define NAZARA_AUDIO_AL_ALC_FUNCTION(name) decltype(&::name) name;

View File

@@ -28,6 +28,18 @@
#define NAZARA_AUDIO_AL_EXT_END()
#endif
#ifndef NAZARA_AUDIO_ALC_EXT_FUNCTION
#define NAZARA_AUDIO_ALC_EXT_FUNCTION(func) NAZARA_AUDIO_AL_EXT_FUNCTION(func)
#endif
#ifndef NAZARA_AUDIO_ALC_EXT_BEGIN
#define NAZARA_AUDIO_ALC_EXT_BEGIN(ext) NAZARA_AUDIO_AL_EXT_BEGIN(ext)
#endif
#ifndef NAZARA_AUDIO_ALC_EXT_END
#define NAZARA_AUDIO_ALC_EXT_END() NAZARA_AUDIO_AL_EXT_END()
#endif
NAZARA_AUDIO_AL_FUNCTION(alBuffer3f)
NAZARA_AUDIO_AL_FUNCTION(alBuffer3i)
NAZARA_AUDIO_AL_FUNCTION(alBufferData)
@@ -102,7 +114,7 @@ NAZARA_AUDIO_AL_FUNCTION(alSourceStopv)
NAZARA_AUDIO_AL_FUNCTION(alSourceUnqueueBuffers)
NAZARA_AUDIO_AL_FUNCTION(alSpeedOfSound)
#ifndef NAZARA_PLATFORM_WEB
#ifdef AL_SOFT_source_latency
NAZARA_AUDIO_AL_EXT_BEGIN(AL_SOFT_source_latency)
NAZARA_AUDIO_AL_EXT_FUNCTION(alGetSource3dSOFT)
NAZARA_AUDIO_AL_EXT_FUNCTION(alGetSource3i64SOFT)
@@ -140,9 +152,19 @@ NAZARA_AUDIO_ALC_FUNCTION(alcOpenDevice)
NAZARA_AUDIO_ALC_FUNCTION(alcProcessContext)
NAZARA_AUDIO_ALC_FUNCTION(alcSuspendContext)
#ifdef ALC_EXT_thread_local_context
NAZARA_AUDIO_ALC_EXT_BEGIN(ALC_EXT_thread_local_context)
NAZARA_AUDIO_ALC_EXT_FUNCTION(alcGetThreadContext)
NAZARA_AUDIO_ALC_EXT_FUNCTION(alcSetThreadContext)
NAZARA_AUDIO_ALC_EXT_END()
#endif
#undef NAZARA_AUDIO_AL_FUNCTION
#undef NAZARA_AUDIO_AL_ALC_FUNCTION
#undef NAZARA_AUDIO_AL_EXT_FUNCTION
#undef NAZARA_AUDIO_ALC_FUNCTION
#undef NAZARA_AUDIO_AL_EXT_BEGIN
#undef NAZARA_AUDIO_AL_EXT_END
#undef NAZARA_AUDIO_ALC_EXT_FUNCTION
#undef NAZARA_AUDIO_ALC_EXT_BEGIN
#undef NAZARA_AUDIO_ALC_EXT_END
#undef NAZARA_AUDIO_ALC_FUNCTION