xaudio2: Always set current OpenAL context before making AL calls.

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Andrew Eikum 2016-07-06 14:48:18 -05:00 committed by Alexandre Julliard
parent d72d640308
commit 49078e00a5
1 changed files with 19 additions and 6 deletions

View File

@ -36,6 +36,7 @@ WINE_DECLARE_DEBUG_CHANNEL(winediag);
static ALCdevice *(ALC_APIENTRY *palcLoopbackOpenDeviceSOFT)(const ALCchar*);
static void (ALC_APIENTRY *palcRenderSamplesSOFT)(ALCdevice*, ALCvoid*, ALCsizei);
static ALCboolean (ALC_APIENTRY *palcSetThreadContext)(ALCcontext*);
static HINSTANCE instance;
@ -101,6 +102,12 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD reason, void *pReserved)
return FALSE;
}
if(!alcIsExtensionPresent(NULL, "ALC_EXT_thread_local_context") ||
!(palcSetThreadContext = alcGetProcAddress(NULL, "alcSetThreadContext"))){
ERR("XAudio2 requires the ALC_EXT_thread_local_context extension (OpenAL-Soft >= 1.12)\n");
return FALSE;
}
break;
}
return TRUE;
@ -313,6 +320,8 @@ static HRESULT WINAPI XA2SRC_SetVolume(IXAudio2SourceVoice *iface, float Volume,
al_gain = Volume;
palcSetThreadContext(This->xa2->al_ctx);
alSourcef(This->al_src, AL_GAIN, al_gain);
return S_OK;
@ -366,6 +375,8 @@ static void WINAPI XA2SRC_DestroyVoice(IXAudio2SourceVoice *iface)
TRACE("%p\n", This);
palcSetThreadContext(This->xa2->al_ctx);
EnterCriticalSection(&This->lock);
if(!This->in_use){
@ -728,6 +739,8 @@ static HRESULT WINAPI XA2SRC_SetFrequencyRatio(IXAudio2SourceVoice *iface,
else
r = Ratio;
palcSetThreadContext(This->xa2->al_ctx);
alSourcef(This->al_src, AL_PITCH, r);
return S_OK;
@ -740,6 +753,8 @@ static void WINAPI XA2SRC_GetFrequencyRatio(IXAudio2SourceVoice *iface, float *p
TRACE("%p, %p\n", This, pRatio);
palcSetThreadContext(This->xa2->al_ctx);
alGetSourcef(This->al_src, AL_PITCH, &ratio);
*pRatio = ratio;
@ -1377,6 +1392,8 @@ static HRESULT WINAPI IXAudio2Impl_CreateSourceVoice(IXAudio2 *iface,
dump_fmt(pSourceFormat);
palcSetThreadContext(This->al_ctx);
EnterCriticalSection(&This->lock);
LIST_FOR_EACH_ENTRY(src, &This->source_voices, XA2SourceImpl, entry){
@ -1752,12 +1769,6 @@ static HRESULT WINAPI IXAudio2Impl_CreateMasteringVoice(IXAudio2 *iface,
goto exit;
}
if(alcMakeContextCurrent(This->al_ctx) == ALC_FALSE){
WARN("alcMakeContextCurrent failed\n");
hr = COMPAT_E_DEVICE_INVALIDATED;
goto exit;
}
hr = IAudioClient_Start(This->aclient);
if (FAILED(hr))
{
@ -2415,6 +2426,8 @@ static DWORD WINAPI engine_threadproc(void *arg)
continue;
}
palcSetThreadContext(This->al_ctx);
do_engine_tick(This);
LeaveCriticalSection(&This->lock);