IAudioClient::IsFormatSupported Method

The IsFormatSupported method indicates whether the audio endpoint device supports a particular stream format.

Syntax

public:
HRESULT IsFormatSupported(
         AUDCLNT_SHAREMODE ShareMode,
         const WAVEFORMATEX *pFormat,
         WAVEFORMATEX **ppClosestMatch
)  

Parameters

ShareMode
Type: AUDCLNT_SHAREMODE 

[in]

The sharing mode for the stream format. The only supported value on Xbox One is AUDCLNT_SHAREMODE_SHARED.

pFormat
Type: WAVEFORMATEX *

[in]

Pointer to the specified stream format. This parameter points to a caller-allocated format descriptor of type WAVEFORMATEX or WAVEFORMATEXTENSIBLE. The client writes a format description to this structure before calling this method. For information about WAVEFORMATEX and WAVEFORMATEXTENSIBLE, see the Windows DDK documentation.

ppClosestMatch
Type: WAVEFORMATEX **

[out, optional]

Pointer to a pointer variable into which the method writes the address of a WAVEFORMATEX orWAVEFORMATEXTENSIBLE structure. This structure specifies the supported format that is closest to the format that the client specified through the pFormat parameter. Set ppClosestMatch to point to a valid, non-NULL pointer variable. The method allocates the storage for the structure. The caller is responsible for freeing the storage, when it is no longer needed, by calling the CoTaskMemFree function. If the IsFormatSupported call fails and ppClosestMatch is non-NULL, the method sets ppClosestMatch* to **NULL. For information about CoTaskMemFree, see the Windows SDK documentation.

Return value

Type: HRESULT 

If the operation fails, possible return codes include, but are not limited to, the values shown in the following table.

Return codes
Return code Description
S_OK Succeeded and the audio endpoint device supports the specified stream format.
S_FALSE Succeeded with a closest match to the specified format.
AUDCLNT_E_UNSUPPORTED_FORMAT Succeeded but the specified format is not supported by Xbox One. Xbox One only supports FLOAT32 sample types.

Return codes
Return code Description
E_POINTER Parameter pFormat is NULL, or ppClosestMatch is NULL and ShareMode is AUDCLNT_SHAREMODE_SHARED.
E_INVALIDARG Parameter ShareMode is not AUDCLNT_SHAREMODE_SHARED.
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 audio service is not running.

Refer to WASAPI error codes.

Remarks

This method provides a way for a client to determine, before calling IAudioClient::Initialize, whether the audio engine supports a particular stream format.

For shared mode, if the audio engine supports the caller-specified format, IsFormatSupported sets *ppClosestMatch to NULL and returns S_OK. If the audio engine does not support the caller-specified format but does support a similar format, the method retrieves the similar format through the ppClosestMatch parameter and returns S_FALSE. If the audio engine does not support the caller-specified format or any similar format, the method sets ppClosestMatch* to **NULL and returns AUDCLNT_E_UNSUPPORTED_FORMAT.

In shared mode, the audio engine always supports the mix format, which the client can obtain by calling the IAudioClient::GetMixFormat method. In addition, the audio engine might support similar formats that have the same sample rate and number of channels as the mix format but differ in the representation of audio sample values. The audio engine represents sample values internally as floating-point numbers, but if the caller-specified format represents sample values as integers, the audio engine typically can convert between the integer sample values and its internal floating-point representation.

The audio engine might be able to support an even wider range of shared-mode formats if the installation package for the audio device includes a local effects (LFX) audio processing object (APO) that can handle format conversions. An LFX APO is a software module that performs device-specific processing of an audio stream. The audio graph builder in The audio service inserts the LFX APO into the stream between each client and the audio engine. When a client calls the IsFormatSupported method and the method determines that an LFX APO is installed for use with the device, the method directs the query to the LFX APO, which indicates whether it supports the caller-specified format.

For example, a particular LFX APO might accept a 6-channel surround sound stream from a client and convert the stream to a stereo format that can be played through headphones. Typically, an LFX APO supports only client formats with sample rates that match the sample rate of the mix format.

For more information about APOs, see the white papers titled “Custom Audio Effects in Windows Vista” and “Reusing the Windows Vista Audio System Effects” at the Audio Device Technologies for Windows website. For more information about the IsFormatSupported method, see Device Formats.

Requirements

Header: Declared in audioclient.h.

Library: Use mmdevapi.lib.

See also

IAudioClient

IAudioClient Members