IMMDeviceEnumerator::GetDefaultAudioEndpoint Method

The GetDefaultAudioEndpoint method retrieves the default audio endpoint for the specified data-flow direction (playback or capture).

Syntax

public:
HRESULT GetDefaultAudioEndpoint(
         EDataFlow dataFlow,
         ERole role,
         IMMDevice **ppEndpoint
)  

Parameters

dataFlow
Type: EDataFlow 

[in]

The data-flow direction for the endpoint device. The caller should set this parameter to one of the following two EDataFlow enumeration values:

eRender

eCapture

The data-flow direction for a rendering device is eRender. The data-flow direction for a capture device is eCapture.

role
Type: ERole 

[in]

The role of the endpoint device. The caller should set this parameter to one of the following ERole enumeration values:

eConsole

eMultimedia

eCommunications

For more information, see Remarks.

ppEndpoint
Type: IMMDevice **

[out] Pointer to a pointer variable into which the method writes the address of the IMMDevice interface of the endpoint object for the default audio endpoint device. 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 GetDefaultAudioEndpoint call fails, *ppDevice is NULL.

Return value

Type: HRESULT 

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 codes
Return code Description
E_POINTER Parameter ppDevice is NULL.
E_INVALIDARG Parameter dataFlow or role is out of range.
E_NOTFOUND No device is available.
E_OUTOFMEMORY Out of memory.

Refer to WASAPI error codes.

Remarks

This method retrieves the default endpoint device for the specified data-flow direction (playback or capture). For example, a client can get the default console playback device by making the following call:

Example

  hr = pDevEnum->GetDefaultAudioEndpoint(
                   eRender, eConsole, &pDeviceOut);  

In the preceding code fragment, variable hr is of type HRESULT, pDevEnum is a pointer to an IMMDeviceEnumerator interface, and pDeviceOut is a pointer to an IMMDevice interface.

For capture, on Xbox One this method will always return the endpoint for the Kinect sensor, even if the sensor is not connected at the time of the call.

For playback, on Xbox One this method will always return the endpoint for the HDMI/SPDIF output.

Requirements

Header: Declared in mmdeviceapi.h.

Library: Use MMDevApi.lib.

See also

IMMDeviceEnumerator

IMMDeviceEnumerator Members