XAudio2Create function (xaudio2.h)

Creates a new XAudio2 object and returns a pointer to its IXAudio2 interface.

Syntax

HRESULT XAudio2Create(
  [out] IXAudio2          **ppXAudio2,
  [in]  UINT32            Flags,
  [in]  XAUDIO2_PROCESSOR XAudio2Processor
);

Parameters

[out] ppXAudio2

If the operation is successful, returns a pointer to an IXAudio2 object.

[in] Flags

Flags that specify the behavior of the IXAudio2 object. The value of this parameter must be 0.

[in] XAudio2Processor

An XAUDIO2_PROCESSOR-typed value that specifies which CPU to use. If multiple bits are specified, the system will create a separate worker thread for each processor.

XAUDIO2_PROCESSOR default value is XAUDIO2_DEFAULT_PROCESSOR.

Warning If you specify XAUDIO2_ANY_PROCESSOR, the system will use all of the device's processors and, as noted above, create a worker thread for each processor.
 
Note  Specifying a processor should generally be avoided because it can interfere with the scheduler's ability to schedule threads effectively across processors. Instead, pass the XAUDIO2_DEFAULT_PROCESSOR value (see below).
 
The special XAUDIO2_DEFAULT_PROCESSOR value causes XAudio2 to use its default processor.

Return value

Returns S_OK if successful, an error code otherwise. See XAudio2 Error Codes for descriptions of XAudio2 specific error codes.

Remarks

The DirectX SDK versions of XAUDIO2 supported a flag XAUDIO2_DEBUG_ENGINE to select between the release and 'checked' version. This flag is not supported or defined in the Windows 8 version of XAUDIO2.

Note  No versions of the DirectX SDK contain the xaudio2.lib import library. DirectX SDK versions use COM to create a new XAudio2 object.
 

Platform Requirements

Windows 10 (XAudio2.9); Windows 8, Windows Phone 8 (XAudio 2.8); DirectX SDK (XAudio 2.7)

Windows Phone 8.1: This API is supported.

Requirements

Requirement Value
Target Platform Windows
Header xaudio2.h
Library Xaudio2.lib
DLL Windows.Media.Audio.dll

See also

How to: Build a Basic Audio Processing Graph

XAudio2 Functions