(Xaudio2) Fix audio device index - since Windows 8, device index

for CreateMasteringVoice is of type LPCWSTR instead of UINT32
This commit is contained in:
twinaphex 2019-07-24 04:10:06 +02:00
parent 16b65c6d61
commit aeb10505c4

View File

@ -219,8 +219,16 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels,
goto error;
#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
if (FAILED(IXAudio2_CreateMasteringVoice(handle->pXAudio2, &handle->pMasterVoice, channels, samplerate, 0, (LPCWSTR)(uintptr_t)device, NULL, AudioCategory_GameEffects)))
goto error;
{
/* Since Windows 8,
* device index is of type LPCWSTR instead of UINT32.
*
* MSDN note: Note that the DirectX SDK XAUDIO2 version of CreateMasteringVoice took a DeviceIndex argument instead of a szDeviceId */
XAUDIO2_DEVICE_DETAILS dev_detail;
IXAudio2_GetDeviceDetails(handle->pXAudio2, device, &dev_detail);
if (FAILED(IXAudio2_CreateMasteringVoice(handle->pXAudio2, &handle->pMasterVoice, channels, samplerate, 0, (LPCWSTR)dev_detail.DeviceID, NULL, AudioCategory_GameEffects)))
goto error;
}
#else
if (FAILED(IXAudio2_CreateMasteringVoice(handle->pXAudio2, &handle->pMasterVoice, channels, samplerate, 0, device, NULL)))
goto error;