Enables Windows Store apps to access preexisting Component Object Model (COM) interfaces in the WASAPI family.
HRESULT ActivateAudioInterfaceAsync( LPCWSTR deviceInterfacePath, REFIID riid, PROPVARIANT *activationParams, IActivateAudioInterfaceCompletionHandler *completionHandler, IActivateAudioInterfaceAsyncOperation **activationOperation );
The GUIDs DEVINTERFACE_AUDIO_CAPTURE and DEVINTERFACE_AUDIO_RENDER represent the default audio capture and render device respectively. Call StringFromIID to convert either of these GUIDs to an LPCWSTR to use for this argument.
Interface-specific activation parameters. For more information, see the pActivationParams parameter in IMMDevice::Activate.
An interface implemented by the caller that is called by Windows when the result of the activation procedure is available.
Returns an IActivateAudioInterfaceAsyncOperation interface that represents the asynchronous operation of activating the requested WASAPI interface.
The function returns an HRESULT. Possible values include, but are not limited to, those in the following table.
||The underlying object and asynchronous operation were created successfully.|
||This error may result if the function is called from an incorrect COM apartment, or if the passed IActivateAudioInterfaceCompletionHandler is not implemented on an agile object (aggregating a free-threaded marshaler).|
This function enables Windows Store apps to activate certain WASAPI COM interfaces after using Windows Runtime APIs in the Windows.Devices and Windows.Media.Devices namespaces to select an audio device.
An application must call this function from the main UI thread to activate a COM interface in the WASAPI family. The application passes an IActivateAudioInterfaceCompletionHandler callback COM interface through completionHandler. Windows calls a method in the application’s IActivateAudioInterfaceCompletionHandler interface from a worker thread in the COM Multi-threaded Apartment (MTA) when the activation results are available. The application can then call a method in the IActivateAudioInterfaceAsyncOperation interface to retrieve the result code and the requested WASAPI interface.
Windows holds a reference to the application's IActivateAudioInterfaceCompletionHandler interface until the operation is complete and the application releases the IActivateAudioInterfaceAsyncOperation interface.
Applications must not free the object implementing the IActivateAudioInterfaceCompletionHandler until the completion handler callback has executed.
ActivateAudioInterfaceAsync must be called on the main UI thread so that the consent prompt can be shown. If the consent prompt can’t be shown, the user can’t grant device access to the app.
ActivateAudioInterfaceAsync must be called on a thread in a COM Single-Threaded Apartment (STA). The completionHandler that is passed into ActivateAudioInterfaceAsync needs to implement IAgileObject to ensure that there is no deadlock when the completionHandler is called from the MTA. Otherwise, an E_ILLEGAL_METHOD_CALL will occur.
|Windows version||Windows 8 [desktop apps | UWP apps] Windows Server 2012 [desktop apps | UWP apps]|
|Header||mmdeviceapi.h (include Mmdevapi.idl)|