Share via


IAudioClient::GetService

Previous Next

IAudioClient::GetService

The GetService method accesses additional services from the audio client object.

HRESULT GetService(
  REFIID  riid,
  void  **ppv
);

Parameters

riid

[in]  The interface ID for the requested service. The client should set this parameter to one of the following REFIID values:

IID_IAudioCaptureClient

IID_IAudioClock

IID_IAudioRenderClient

IID_IAudioSessionControl

IID_IAudioStreamVolume

IID_IChannelAudioVolume

IID_ISimpleAudioVolume

For more information, see Remarks.

ppv

[out]  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
E_POINTER Parameter ppv is NULL.
E_NOINTERFACE The requested interface is not available.
AUDCLNT_E_NOT_INITIALIZED The audio stream has not been initialized.
AUDCLNT_E_WRONG_ENDPOINT_TYPE The caller tried to access an IAudioCaptureClient interface on a rendering endpoint, or an IAudioRenderClient interface on a capture endpoint.
AUDCLNT_E_DEVICE_INVALIDATED 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.
AUDCLNT_E_SERVICE_NOT_RUNNING 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:

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

Client: Windows Vista

Header: Include Audioclient.h.

See Also

Previous Next