The Windows Audio Session API (WASAPI) enables client applications to manage the flow of audio data between the application and an audio endpoint device.
Header files Audioclient.h and Audiopolicy.h define the WASAPI interfaces.
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.
|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.|
|IAudioClock||Enables a client to monitor a stream's data rate and the current position in the stream.|
|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.|
|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.
|IAudioSessionEvents||Provides notifications of session-related events such as changes in the volume level, display name, and session state.|