audio capture in metro apps

2019-05-08 19:08发布

问题:

I need to perform low-level audio capture in my Windows 8 Metro-style app.

I guess I need to use the IAudioClient interface, but how to get that interface?

Microsoft says "A client obtains a reference to an IAudioClient interface for an audio endpoint device by using one of the techniques described in IMMDevice Interface.."

http://msdn.microsoft.com/en-us/library/windows/desktop/dd370865(v=vs.85).aspx

but IMMDevice interface is not supported for Metro-style apps.

How does one get an IAudioClient interface ?

回答1:

I got an answer from the MSDN forums:

Platform::String^ id = Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId(Windows::Media::Devices::AudioDeviceRole::Console );
Microsoft::WRL::ComPtr<IAudioClient> pAudioClient = NULL;
ActivateAudioInterface( id->Data(), __uuidof( IAudioClient ), (void**)&pAudioClient );

This ActivateAudioInterface() is mysterious to me—there are no references to it at all in the MSDN Library; the only hits on searches for it are in the forums...



回答2:

Actually, you should use ActivateAudioInterfaceAsync instead of ActivateAudioInterface. See http://msdn.microsoft.com/en-us/library/windows/desktop/jj128298(v=vs.85).aspx