XAudio2: Call CoInitializeEx to prevent errors

I could not properly reset the audio backend and call CreateMasteringVoice without getting errors
This commit is contained in:
Megamouse 2020-06-20 02:43:08 +02:00
parent 5b7ee43352
commit 8ee953ef8e

View File

@ -19,6 +19,10 @@ XAudio2Backend::XAudio2Backend()
{
Microsoft::WRL::ComPtr<IXAudio2> instance;
// In order to prevent errors on CreateMasteringVoice, apparently we need CoInitializeEx according to:
// https://docs.microsoft.com/en-us/windows/win32/api/xaudio2fx/nf-xaudio2fx-xaudio2createvolumemeter
CoInitializeEx(NULL, COINIT_MULTITHREADED);
HRESULT hr = XAudio2Create(instance.GetAddressOf(), 0, XAUDIO2_DEFAULT_PROCESSOR);
if (FAILED(hr))
{