MinGW64 Issues with WASAPI (error: 800401f0)


Now that I have my MinGW64 version of JUCE compiling with WASAPI support, I'm on to the next issue... a failure when trying to detect / initialize WASAPI. This makes me question whether my fixes to get JUCE compiling on MinGW64 have broken something further down the line (http://www.juce.com/forum/topic/compiler-error-mingw64-windows-10).

juce::WasapiClasses::WASAPIAudioIODeviceType::scan juce_win32_WASAPI.cpp:1544
if (! check (enumerator.CoCreateInstance (__uuidof (MMDeviceEnumerator))))

results in "WASAPI error: 800401f0"

Basically, when CoCreateInstance(__uuidof (MMDeviceEnumerator)) runs, it returns an HRESULT of -2147221008 (i.e. 0x800401F0 - CO_E_NOTINITIALIZED). When I compile this same example in Visual Studio 2010, it works fine (on the same computer). So, this seems to be clearly related to the compiling on MinGW64... and something going wrong with these COM wrappers and macros. =)

If anyone has some ideas as to what's causing this, or any possible work-arounds, I would be super appreciative! 




So, it would appear the comments in JUCE are pointing to the fact I should be calling 


from the thread that is running the WASAPI code. However, my example that works on VisualStudio 2010, does not seem to invoke that method (CoInitialize)... or, at least I'm not seeing where that happens.

It does fix my WASAPI issues on MinGW64 when I squeeze this method into the AudioDeviceManager::initialise() method... but I'm pretty sure that is not a good solution. =)

Any thoughts on where this CoInitialize(0) call should go?   Thanks!


The JUCE message thread would have already called CoInitialise, but if you're calling this stuff from your own thread, then you'd need to call it once at the start of your thread.

TBH I should probably make it do so internally when you try to invoke things like WASAPI - might add that. But to get rolling, it won't do any harm to add your own call to it.