Edit

Share via


About WASAPI

The Windows Audio Session API (WASAPI) enables client applications to manage the flow of audio data between the application and an audio endpoint device.

The WASAPI interfaces are defined in the header files, Audioclient.h and Audiopolicy.h.

Every audio stream is a member of an audio session. Through the session abstraction, a WASAPI client can identify an audio stream as a member of a group of related audio streams. The system can manage all of the streams in the session as a single unit.

The audio engine is the user-mode audio component through which applications share access to an audio endpoint device. The audio engine transports audio data between an endpoint buffer and an endpoint device. To play an audio stream through a rendering endpoint device, an application periodically writes audio data to a rendering endpoint buffer. The audio engine mixes the streams from the various applications. To record an audio stream from a capture endpoint device, an application periodically reads audio data from a capture endpoint buffer.

WASAPI consists of several interfaces. The first of these is the IAudioClient interface. To access the WASAPI interfaces, a client first obtains a reference to the IAudioClient interface of an audio endpoint device by calling the IMMDevice::Activate method with parameter iid set to REFIID IID_IAudioClient. The client calls the IAudioClient::Initialize method to initialize a stream on an endpoint device. After initializing a stream, the client can obtain references to the other WASAPI interfaces by calling the IAudioClient::GetService method.

Many of the methods in WASAPI return error code AUDCLNT_E_DEVICE_INVALIDATED if the audio endpoint device that a client application is using becomes invalid. Frequently, the application can recover from this error. For more information, see Recovering from an Invalid-Device Error.

WASAPI implements the following interfaces.

Interface Description
IAcousticEchoCancellationControl Provides a mechanism for determining if an audio capture endpoint supports acoustic echo cancellation (AEC) and, if so, allows the client to set the audio render endpoint that should be used as the reference stream.
IAudioCaptureClient Enables a client to read input data from a capture endpoint buffer.
IAudioClient Enables a client to create and initialize an audio stream between an audio application and the audio engine or the hardware buffer of an audio endpoint device.
IAudioClient2 Enables a client to opt in for offloading, query stream properties, and get information from the hardware that handles offloading.
IAudioClient3 Enables a client to query for the audio engine's supported periodicities and current periodicity as well as request initialization of a shared audio stream with a specified periodicity.
IAudioClientDuckingControl Provides a method that allows an app to specify that the system shouldn't duck the audio of other streams when the app's audio render stream is active.
IAudioClock Enables a client to monitor a stream's data rate and the current position in the stream.
IAudioClock2 Enables a client to get the current device position.
IAudioClockAdjustment Enables a client to adjust the sample rate of a stream.
IAudioEffectsManager Provides management functionality for the audio effects pipeline.
IAudioRenderClient Enables a client to write output data to a rendering endpoint buffer.
IAudioSessionControl Enables a client to configure the control parameters for an audio session and to monitor events in the session.
IAudioSessionManager Enables a client to access the session controls and volume controls for both cross-process and process-specific audio sessions.
IAudioStreamVolume Enables a client to control and monitor the volume levels for all of the channels in an audio stream.
IAudioViewManagerService Provides APIs for associating an HWND with an audio stream.
IChannelAudioVolume Enables a client to control the volume levels for all of the channels in the audio session that the stream belongs to.
ISimpleAudioVolume Enables a client to control the master volume level of an audio session.

WASAPI clients that require notification of session-related events should implement the following interface.

Interface Description
IAudioEffectsChangedNotificationClient A callback interface that allows applications to receive notifications when the list of audio effects changes or the resources needed to enable an effect changes.
IAudioSessionEvents Provides notifications of session-related events such as changes in the volume level, display name, and session state.

Stream Management

Programming Reference