On 06/30/2016 12:07 PM, Andrew Eikum wrote:
if(!alcIsExtensionPresent(NULL, "ALC_SOFT_loopback") || !(palcLoopbackOpenDeviceSOFT = alcGetProcAddress(NULL, "alcLoopbackOpenDeviceSOFT")) ||
!(palcRenderSamplesSOFT = alcGetProcAddress(NULL, "alcRenderSamplesSOFT"))){
!(palcRenderSamplesSOFT = alcGetProcAddress(NULL, "alcRenderSamplesSOFT")) ||
!(palcSetThreadContext = alcGetProcAddress(NULL, "alcSetThreadContext"))){ ERR("XAudio2 requires the ALC_SOFT_loopback extension (OpenAL-Soft >= 1.14)\n"); return FALSE; }
alcSetThreadContext isn't part of the ALC_SOFT_loopback extension, you should check for ALC_EXT_thread_local_context instead.
+static void context_lock(ALCcontext *ctx) +{
- EnterCriticalSection(&al_lock);
- alcMakeContextCurrent(ctx);
+}
+static void context_unlock(void) +{
- LeaveCriticalSection(&al_lock);
+}
Since you're relying on ALC_EXT_thread_local_context anyway, it would probably be better to use alcSetThreadContext in context_lock, which would allow you to get rid of the global lock for normal calls (another thread can't change the current thread context on you, and unlike OpenGL, the same context can be current on multiple threads at the same time).