> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XDK vs GDK audio API comparison

> Comparison of XBOX One Software Development Kit and Microsoft Game Development Kit Audio API

This topic describes how the Audio APIs in the XBOX One Software Development Kit were changed for Microsoft Game Development Kit (GDK).

## Guidelines

* To help ensure that users have the best gaming experience possible, determine if the endpoint supports multichannel audio. First, call [IAudioClient::IsFormatSupported](https://learn.microsoft.com/windows/desktop/api/audioclient/nf-audioclient-iaudioclient-isformatsupported). If the preferred format isn't supported, fall back to rendering to the mix format, [IAudioClient::GetMixFormat](https://learn.microsoft.com/windows/desktop/api/audioclient/nf-audioclient-iaudioclient-getmixformat).

* Instead of handling only 7.1 endpoints, titles must also be able to handle 2.0, 5.1, and 7.1 endpoints natively and react in real-time if formats change through audio client invalidations. If a title doesn't want to provide three (with respect to the channel counts) different sources of audio, it can ask the OS to perform the upmixing and downmixing for it, with the [AUDCLNT\_STREAMFLAGS\_AUTOCONVERTPCM](https://learn.microsoft.com/windows/desktop/coreaudio/audclnt-streamflags-xxx-constants) streamflag on Audioclient initialize. Even if the game asks the OS to perform upmixing and downmixing, it will still receive
  and be required to react to audio client invalidations.

* To enumerate (render and capture) audio devices, use the [MMDevice API](https://learn.microsoft.com/windows/desktop/coreaudio/mmdevice-api). If rendering audio to the main HDMI endpoint only, call [GetDefaultAudioEndpoint](https://learn.microsoft.com/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdeviceenumerator-getdefaultaudioendpoint)

* On XBOX, render audio from one process at a time.

* XBOX Manager remote control is designed to support audio through [Windows Audio Session API ](/build/console-features/audio/overviews/wasapi-overview) (WASAPI). However, it does not support audio streaming from [ISpatialAudioClient](/build/console-features/audio/overviews/spatial-audio-overview) (ISAC) when Dolby/DTS home theater settings are activated.

* Many methods associated with WASAPI may return error code [AUDCLNT\_E\_DEVICE\_INVALIDATED](https://learn.microsoft.com/windows/win32/api/audioclient/nf-audioclient-iaudioclient-start) if the audio endpoint device that the client application is using becomes invalid. Ensure that your title is responding properly to these errors which may occur if an endpoint device is changed in any way. More information on recovering from an invalid device error with WASAPI is [here](https://learn.microsoft.com/windows/win32/coreaudio/recovering-from-an-invalid-device-error). An easy way to confirm that your title handles audio device invalidation correctly is by switching to the audio settings page while your title is running and changing the channel count on the HDMI device. During an invalidation scenario, the following error codes can be returned by WASAPI:

  * AUDCLNT\_E\_DEVICE\_INVALIDATED

  * AUDCLNT\_E\_RESOURCES\_INVALIDATED

  * AUDCLNT\_E\_UNSUPPORTED\_FORMAT

  * AUDCLNT\_E\_ENDPOINT\_CREATE\_FAILED

* When Spatial Sound is used by your title you will be interacting with the ISAC APIs and they also return error codes surrounding device invalidation. For ISAC, invalidation occurs when the audio endpoint is changed or the spatial rendering mode is changed during playback. More information on recovering from an invalid device error with ISAC is [here](https://learn.microsoft.com/windows/win32/coreaudio/recovering-from-an-invalid-device-error-spatial-sound). This happens when any of the following methods returns one of the following values.

  Methods:

  * [ISpatialAudioObjectRenderStreamBase](https://learn.microsoft.com/windows/win32/api/spatialaudioclient/nn-spatialaudioclient-ispatialaudioobjectrenderstreambase)

  * [ISpatialAudioObjectRenderStream](https://learn.microsoft.com/windows/win32/api/spatialaudioclient/nn-spatialaudioclient-ispatialaudioobjectrenderstream)

  * [ISpatialAudioObjectRenderStreamForMetadata](https://learn.microsoft.com/windows/win32/api/spatialaudiometadata/nn-spatialaudiometadata-ispatialaudioobjectrenderstreamformetadata)

  * [ISpatialAudioObjectRenderStreamForHrtf](https://learn.microsoft.com/windows/win32/api/spatialaudiohrtf/nn-spatialaudiohrtf-ispatialaudioobjectrenderstreamforhrtf)

  Values:

  * SPTLAUDCLNT\_E\_DESTROYED
  * AUDCLNT\_E\_DEVICE\_INVALIDATED
  * AUDCLNT\_E\_RESOURCES\_INVALIDATED
  * AUDCLNT\_E\_UNSUPPORTED\_FORMAT
  * SPTLAUDCLNT\_E\_INTERNAL

    Additionally, plugging in or unplugging a headset from the controller when the console is set up to use a Spatial format (like Windows Sonic for Headphones) will likely lead to these events.

* An audio device invalidation can occur at any time after the [IMMDevice](https://learn.microsoft.com/windows/win32/api/mmdeviceapi/nn-mmdeviceapi-immdevice) is obtained from the [MMDevice API](https://learn.microsoft.com/windows/desktop/coreaudio/mmdevice-api). All calls including [IMMDevice::Activate](https://learn.microsoft.com/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdevice-activate) can return an invalidation error. Anytime the game encounters an invalidation error, it should re-create its audio streams by first obtaining a new IMMDevice through [IMMDeviceEnumerator](https://learn.microsoft.com/windows/win32/api/mmdeviceapi/nf-mmdeviceapi-immdevice-activate).

## Changes in API

\| Target platform| XBOX One Software Development Kit API| Microsoft Game Development Kit (GDK) API replacement| Description|
\| --- | --- | --- | --- | --- | --- | --- | --- | --- |
\| PC and XBOX| ActivateAudioInterfaceAsync and IActivateAudioInterfaceAsync| [IMMDevice::Activate()](https://learn.microsoft.com/windows/desktop/api/mmdeviceapi/nf-mmdeviceapi-immdevice-activate)| To activate an audio client synchronously from an [IMMDevice](https://learn.microsoft.com/windows/desktop/api/Mmdeviceapi/nn-mmdeviceapi-immdevice). Use [MMDevice API](https://learn.microsoft.com/windows/desktop/coreaudio/mmdevice-api) to enumerate endpoints.|
\| PC and XBOX| IAudioClient2::RegisterXBoxVolumeNotificationCallback and IAudioClient2::UnregisterXBoxVolumeNotificationCallback| [AudioStateMonitor API](/reference/audio/audiostatemonitor/interfaces/iaudiostatemonitor)| These APIs were previously intended to alert titles that game media streams were attenuated. The new way of doing it is by using the [AudioStateMonitor API](/reference/audio/audiostatemonitor/interfaces/iaudiostatemonitor).|
\| PC and XBOX| ExcludeFromGameDVRCapture| Not applicable| When creating an [AudioClient](https://learn.microsoft.com/windows/desktop/api/audioclient/nf-audioclient-iaudioclient-initialize), use AUDCLNT\_STREAMFLAGS\_EXCLUDE\_FROM\_GAMEDVR\_CAPTURE as a StreamFlags constant. Include XAUDIO2XBOX.H.|
\| PC and XBOX| IMMGameDVRDeviceCreator| Not applicable| Deprecated.|
\| XBOX| IMMXBoxDevice| Not applicable| Deprecated.|
\| PC and XBOX| GetPnpId| Not applicable| Deprecated.|
\| XBOX| IMMXboxDeviceEnumerator| [IAudioClient::GetMixFormat](https://learn.microsoft.com/windows/desktop/api/audioclient/nf-audioclient-iaudioclient-getmixformat)| |
\| XBOX| GetHdAudioChannelCounts, RegisterChannelCountNotificationCallback, and UnregisterChannelCountNotificationCallback| [IAudioClient::GetMixFormat](https://learn.microsoft.com/windows/desktop/api/audioclient/nf-audioclient-iaudioclient-getmixformat)| If the endpoint format changes, your streams will be invalidated. The next call to [IAudioClient::GetMixFormat](https://learn.microsoft.com/windows/desktop/api/audioclient/nf-audioclient-iaudioclient-getmixformat) will return the appropriate channel count for the endpoint.|
\| XBOX| DisableBitStreamOut and RestoreBitstreamOut| Not applicable| Deprecated.|
\| PC and XBOX| EnableSpatialAudio| Not applicable| Call is no longer required to use Spatial Sound.|
\| PC and XBOX| SetWasapiThreadAffinityMask| Not applicable| Deprecated. Games that use XAudio2 can choose to adjust the *XAudio2Processor* parameter with [XAudio2CreateWithSharedContexts](/reference/audio/xaudio2xbox/functions/xaudio2createwithsharedcontexts) to specify which processor XAudio2 runs on.|

## Reference API documentation

* [AudioStateMonitor (API contents)](/reference/audio/audiostatemonitor/audiostatemonitor_members)
* [XAudio2Xbox (API contents)](/reference/audio/xaudio2xbox/xaudio2xbox_members)
  * Functions
    * [XAudio2CreateWithSharedContexts](/reference/audio/xaudio2xbox/functions/xaudio2createwithsharedcontexts)

## See also

[Microsoft Game Development Kit samples list](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/development-downloads/gdk-samples-list)


## Related topics

- [AudioStateMonitor](/reference/audio/audiostatemonitor/audiostatemonitor_members.md)
- [Game mesh communication: GDK vs XDK differences](/build/console-features/networking/xdk-migration/xdk-migration-game-mesh-networking.md)
- [Multiplayer servers comparison](/services/playfab/multiplayer/servers/server-comparison.md)
- [WASAPI](/build/console-features/audio/overviews/wasapi-overview.md)
- [SHAPE audio flowgraph construction best practices](/build/console-features/audio/overviews/best-practices-audio-flowgraph-construction.md)
