IAudioClient::GetService method (audioclient.h)
The GetService method accesses additional services from the audio client object.
Syntax
HRESULT GetService(
[in] REFIID riid,
[out] void **ppv
);
Parameters
[in] riid
The interface ID for the requested service. The client should set this parameter to one of the following REFIID values:
IID_IAudioCaptureClient
IID_IAudioClientDuckingControl
IID_IAudioClock
IID_IAudioRenderClient
IID_IAudioSessionControl
IID_IAudioStreamVolume
IID_IChannelAudioVolume
IID_IMFTrustedOutput
IID_ISimpleAudioVolume
For more information, see Remarks.
[out] ppv
Pointer to a pointer variable into which the method writes the address of an instance of the requested interface. Through this method, the caller obtains a counted reference to the interface. The caller is responsible for releasing the interface, when it is no longer needed, by calling the interface's Release method. If the GetService call fails, *ppv is NULL.
Return value
If the method succeeds, it returns S_OK. If it fails, possible return codes include, but are not limited to, the values shown in the following table.
Return code | Description |
---|---|
|
Parameter ppv is NULL. |
|
The requested interface is not available. |
|
The audio stream has not been initialized. |
|
The caller tried to access an IAudioCaptureClient interface on a rendering endpoint, or an IAudioRenderClient interface on a capture endpoint. |
|
The audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use. |
|
The Windows audio service is not running. |
Remarks
This method requires prior initialization of the IAudioClient interface. All calls to this method will fail with the error AUDCLNT_E_NOT_INITIALIZED until the client initializes the audio stream by successfully calling the IAudioClient::Initialize method.
The GetService method supports the following service interfaces:
- IAudioCaptureClient
- IAudioClock
- IAudioRenderClient
- IAudioSessionControl
- IAudioStreamVolume
- IChannelAudioVolume
- IMFTrustedOutput
- ISimpleAudioVolume
For information about using trusted audio drivers in OTAs, see Protected User Mode Audio (PUMA).
Note that activating IMFTrustedOutput through this mechanism works regardless of whether the caller is running in PMP. However, if the caller is not running in a protected process (that is, the caller is not within Media Foundation's PMP) then the audio OTA might not operate in the PMP and the protection settings are less robust.
To obtain the interface ID for a service interface, use the __uuidof operator. For example, the interface ID of IAudioCaptureClient is defined as follows:
const IID IID_IAudioCaptureClient __uuidof(IAudioCaptureClient)
For information about the __uuidof operator, see the Windows SDK documentation.
To release the IAudioClient object and free all its associated resources, the client must release all references to any service objects that were created by calling GetService, in addition to calling Release on the IAudioClient interface itself. The client must release a service from the same thread that releases the IAudioClient object.
The IAudioSessionControl, IAudioStreamVolume, IChannelAudioVolume, and ISimpleAudioVolume interfaces control and monitor aspects of audio sessions and shared-mode streams. These interfaces do not work with exclusive-mode streams.
For code examples that call the GetService method, see the following topics:
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | audioclient.h |