[PATCH] xaudio2: Always set current OpenAL context before making AL calls

Chris Robinson chris.kcat at gmail.com
Thu Jun 30 14:47:52 CDT 2016


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).



More information about the wine-devel mailing list