Skip to main content

CreateCaptureAudioStateMonitorForCategoryAndDeviceRole

Creates a new instance of IAudioStateMonitor that monitors the audio level for all audio capture streams in the specified category and with the specified role.

Syntax

Parameters

category
Type: AUDIO_STREAM_CATEGORY
A member of the AUDIO_STREAM_CATEGORY enumeration that specifies the category of the audio capture streams to be monitored. role
Type: ERole
A member of the ERole enumeration that specifies the role of the audio capture streams to be monitored. audioStateMonitor _Out_
Type: IAudioStateMonitor**
This output parameter is populated with the created IAudioStateMonitor object.

Return value

If the method succeeds, it returns S\_OK.

Remarks

This is one of the functions that create and return an AudioStateMonitor instance. There are four variants each for capture and render streams that determine whether a process can do one of the following for a given role:
  • Capture or render any audio of any category
  • Capture or render audio of a specific category
  • Capture or render audio of a specific category, to a specific endpoint.
    The endpoint may be specified using the MMDevice ID (obtained using IMMDevice::GetId()), or by using its SWD ID (obtained using Windows.Devices.Enumeration or Windows.Media.Devices.MediaDevice)
  • Capture or render audio of a specific category to the default endpoint
Consider the following scenario, where a game wants to engage its in-game GameChat functionality only when it knows that the audio will not be muted by the OS policies. In order to do this, the game registers for SoundLevel notifications for the AudioCategory_GameChat stream category on the default communications endpoint. If the SoundLevel for this category is set to ‘Muted’, the game will stop its GameChat session. If the SoundLevel is set to anything else, the game chooses to enable its GameChat stream. The following code example shows how the game can create an appropriate IAudioStateMonitor object for this scenario.

Requirements

Header: Audiostatemonitorapi.h Library: Windows.Media.MediaControl.lib Supported platforms: Windows, XBOX One family consoles and XBOX Series consoles

See also

AUDIO_STREAM_CATEGORY About WASAPI WASAPI
Last modified on August 31, 2026