Freigeben über


Native audio APIs for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Windows Phone 8 apps can use the WASAPI and XAudio2 APIs to play and process audio and manage audio streams. This topic describes these interfaces and the differences between the desktop and phone implementations.

This topic contains the following sections.

XAudio2

XAudio2 is a low-level audio API that you can use to play, mix, and process audio for sound effects in games written in native code. Windows Phone 8 supports the standard XAudio2 feature set you can use on the desktop, although with some exceptions. For example, the desktop supports multiple audio devices, and the phone supports only one. This might affect the parameters you use to call some APIs. Another difference is support for compressed audio data. The XAudio2 interface works only with uncompressed PCM or ADPCM audio data. On the desktop, you can use Microsoft Media Foundation APIs to decompress content into PCM data to use with XAudio2. Windows Phone 8 does not offer these helper APIs, so it will be more difficult to implement a scenario that includes XAudio2 and compressed audio.

If your app uses the XAudio2 APIs, it can potentially drain the user's battery when the user switches to another app and your app continues to run in the background. To ensure that your app does not continue to process audio in the background and drain the user's battery, do the following:

To learn more about the XAudio2 interface, see XAudio2.

WASAPI

You can use the Windows Audio Session API (WASAPI) to manage audio streams in your app. Windows Phone 8 supports a subset of the WASAPI interfaces, and other APIs, that you can use on the desktop. For this list of WASAPI APIs that are supported on the phone, see Audio Capture and Render APIs for native code for Windows Phone.