From 'How to Initialize XAudio2' in Windows Developer
- Microsoft Windows 10 SDK
- Visual Studio 2019 Community
- Microsoft.XAudio2.Redist NuGet package installed
- Intel(R) Pentium(R) CPU 4415Y @ 1.60GHz x64
- Windows 10 Pro for Workstations 64-bit operating system
The following code example:
#include <iostream>
#include <xaudio2.h>
HRESULT init_audio(void)
{
IXAudio2* pXAudio2 = NULL;
HRESULT hr;
if (FAILED(hr = XAudio2Create(&pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR)))
return hr;
IXAudio2MasteringVoice* pMasterVoice = NULL;
if (FAILED(hr = pXAudio2->CreateMasteringVoice(&pMasterVoice)))
return hr;
return hr;
}
int main()
{
std::cout << "Hello World!\n";
std::cout << std::hex << init_audio() << std::endl;
}
directly into a new console solution returns after failing CreateMasteringVoice with the error 800401F0
.
Using any other compiler (GNU, LLVM, Clang) fails to successfully parse XAudio2.h.