> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CreateRenderAudioStateMonitorForCategoryAndDeviceId

> CreateRenderAudioStateMonitorForCategoryAndDeviceId

# CreateRenderAudioStateMonitorForCategoryAndDeviceId

\[部分信息涉及预发布产品,在其正式发布之前可能会发生重大更改。对于此处提供的信息,Microsoft 不作任何明示或默示的担保。]

创建 [IAudioStateMonitor](/reference/audio/audiostatemonitor/interfaces/iaudiostatemonitor) 的新实例,用于监视指定类别中、具有指定 `device` ID 的音频终结点上所有音频呈现流的音频级别。

## Syntax

```cpp theme={null}
HRESULT WINAPI CreateRenderAudioStateMonitorForCategoryAndDeviceId(
  AUDIO_STREAM_CATEGORY category,
  PCWSTR deviceId,
  _Out_ IAudioStateMonitor **audioStateMonitor
);
```

### Parameters

*category*\
Type: AUDIO\_STREAM\_CATEGORY

**AUDIO\_STREAM\_CATEGORY** 枚举的一个成员,用于指定要监视的音频呈现流的类别。

*deviceId*\
Type: PCWSTR

指定要监视其音频呈现流的音频终结点的 `device` ID。

*audioStateMonitor* \_Out\_\
Type: IAudioStateMonitor\*\*

此输出参数将填充所创建的 `IAudioStateMonitor` 对象。

### Return value

Type: HRESULT

如果方法成功,则返回 `S\_OK`。

## Remarks

这是用于创建并返回 `AudioStateMonitor` 实例的其中一个函数。

对于捕获流和呈现流,各有四个变体,用于确定进程是否可以针对给定角色执行以下操作之一:

* 捕获或呈现任意类别的任意音频
* 捕获或呈现特定类别的音频
* 将特定类别的音频捕获或呈现到特定终结点。\
  终结点可以通过 `MMDevice` ID(使用 `IMMDevice::GetId()` 获取)指定,也可以通过其 `SWD` ID(使用 `Windows.Devices.Enumeration` 或 `Windows.Media.Devices.MediaDevice` 获取)指定
* 将特定类别的音频捕获或呈现到默认终结点

## Requirements

**头文件:** Audiostatemonitorapi.h

**库:** Windows.Media.MediaControl.lib

**支持的平台:** Windows、XBOX One 系列主机和 XBOX Series 主机

## See also

[AUDIO\_STREAM\_CATEGORY](https://learn.microsoft.com/windows/win32/api/audiosessiontypes/ne-audiosessiontypes-audio_stream_category)

[关于 WASAPI](https://learn.microsoft.com/windows/desktop/CoreAudio/wasapi)

[WASAPI](/build/console-features/audio/overviews/wasapi-overview)

[音频概述](/build/console-features/audio/overviews/audio)


## Related topics

- [IAudioStateMonitor 接口](/zh-CN/reference/audio/audiostatemonitor/interfaces/iaudiostatemonitor.md)
- [AudioStateMonitor](/zh-CN/reference/audio/audiostatemonitor/audiostatemonitor_members.md)
- [CreateRenderAudioStateMonitorForCategory](/zh-CN/reference/audio/audiostatemonitor/functions/createrenderaudiostatemonitorforcategory.md)
- [CreateRenderAudioStateMonitorForCategoryAndDeviceRole](/zh-CN/reference/audio/audiostatemonitor/functions/createrenderaudiostatemonitorforcategoryanddevicerole.md)
- [CreateCaptureAudioStateMonitorForCategoryAndDeviceId](/zh-CN/reference/audio/audiostatemonitor/functions/createcaptureaudiostatemonitorforcategoryanddeviceid.md)
