microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++
https://walbourn.github.io/directxtk/
MIT License
2.57k stars 511 forks source link

AudioEngineNoAudioHW on Windows 7 #73

Closed rcurtis closed 7 years ago

rcurtis commented 7 years ago

Greetings,

I am currently deploying an app that uses DirectXTK and DirectXTKAudio and getting an exception while initializing the AudioEngine. I am using the DirectXTK_Desktop_2015 solution with the DirectXTKAudio_Desktop_2015_DXSDK for compatibility with Win7 (32 bit). I am getting a list of available devices before creation that gives me:

Speakers (Realtek High Definition Audio)

The device manager says the following devices are available:

NVIDIA High Definition Audio
NVIDIA Virtual Audio Device (Wave Extensible)(WDM)
Realtek High Definition Audio

Any ideas on how I can further debug this?

Thanks, -Rob

walbourn commented 7 years ago

What's the detail of the exception you are getting? What line of code is throwing the exception?

rcurtis commented 7 years ago

The exception is thrown from

AudioEngine::AudioEngine( AUDIO_ENGINE_FLAGS flags, const WAVEFORMATEX* wfx, const wchar_t* deviceId, AUDIO_STREAM_CATEGORY category )

If I check the output it says "Error: XAudio 2.7 not installed on system (install the DirectX End-User Runtimes (June 2010))" - which is installed on the machine.

rcurtis commented 7 years ago

Update: the line

mDLL = LoadLibraryEx( L"XAudioD2_7.DLL", nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ );

reliably fails to load the DLL, but If I copy the DLL from system32 to sit next to the application and switch to LoadLibrary(L"XAudioD2_7.dll"); it works.

walbourn commented 7 years ago

There may be something wrong with your system install then. Try running the XAudio2 samples from here.

sergiubucur commented 7 years ago

I have the same issue. AudioEngine fails to initialize properly on certain environments (different PCs running Win7 x64), even though XAudio2 is properly installed.

I tried the XAudio2 samples and I get the same result. Changing the line

mDLL = LoadLibraryEx( L"XAudioD2_7.DLL", nullptr, 0x00000800 /* LOAD_LIBRARY_SEARCH_SYSTEM32 */ );

to

mDLL = LoadLibraryEx( L"XAudioD2_7.DLL", nullptr, 0);

works for me without having to copy the DLL to the application folder.

On the environments I tested (couple of PCs running Win7 and Win10) this works fine, but I'm not sure if switching the LOAD_LIBRARY_SEARCH_SYSTEM32 flag with 0 is going to behave properly on all environments.

walbourn commented 7 years ago

As to why I'm using this flag at all, see this article and the reason for the explicit load is covered in this post.

On possible reason why this is failing on some Windows 7 systems but not others is if they are missing the KB2533623 update. This update is not included in Windows 7 Service Pack 1, but should be present on fully updated Windows 7 installations. Check to see if the failing systems are missing this update

BTW, be sure to use the latest DXSETUP (April 2011 refresh) to deploy XAudio 2.7 for end-users. See this post.

This is all of course a non-issue with XAudio 2.8 or XAudio 2.9 which is officially an OS DLL in Windows 8 or later and they include support for LOAD_LIBRARY_SEARCH_SYSTEM32 in the OS.