Windows 核心音频 API 中的 ERoles 枚举值代表什么?它们相互排斥吗?

What do the ERoles enumeration values in Windows Core Audio APIs represent? Are they mutually exclusive?

来自 Microsoft API 文档:https://docs.microsoft.com/en-us/windows/win32/api/mmdeviceapi/ne-mmdeviceapi-erole

ERole枚举

typedef enum __MIDL___MIDL_itf_mmdeviceapi_0000_0000_0002 {
  eConsole,
  eMultimedia,
  eCommunications,
  ERole_enum_count
} ERole;

定义音频端点设备选择播放的 "roles" 列表

Constants

  • eConsole Games, system notification sounds, and voice commands.
  • eMultimedia Music, movies, narration, and live music recording.
  • eCommunications Voice communications (talking to another person).
  • ERole_enum_count The number of members in the ERole enumeration (not counting the ERole_enum_count member).

我没有从文档页面得到的是:

  • Music, movies, narration, and live music recording, plus

  • Voice communications (talking to another person)

我不认为答案是肯定的,因为 low-level 硬件或 OS 在没有用户标记的情况下不知道音频流是音乐还是语音。那么这个 ERole 是什么呢?使用目标内容类型播放 "well"(主观上和统计上)的音频混合配置?延迟设置?还是两个或多个属性的组合?

更新

感谢@Roman R. 的回答。现在更多问题仍然符合问题标题:

IMMDeviceEnumerator::GetDefaultAudioEndpoint 的文档说:

HRESULT GetDefaultAudioEndpoint(
  EDataFlow dataFlow,
  ERole     role,
  IMMDevice **ppEndpoint
);

role

The role of the endpoint device. The caller should set this parameter to one of the following ERole enumeration values:

eConsole

eMultimedia

eCommunications

所以只能分配"ONE"个角色;由于 ERole_enum_count 不是大多数枚举自定义协议中的真正选项,因此如何确保“all of the roles”由单个设备播放,如 the Device Roles 和您在那个页面?

Device Roles:

A particular rendering or capture device might be assigned none, one, some, or all of the roles in the preceding table. At any time, each role in the table is assigned to one (and only one) rendering device and to one (and only one) capture device. That is, the assignment of roles to rendering devices is independent of the assignment of roles to capture devices.

上面第一句话回答了角色是否互斥的问题。设备不排除处理音频 I/O。相反,角色定义了在具有多个设备的系统中哪个设备用于特定 activity。例如,通信软件将使用设置为角色 eCommunications 的设备进行音频 capture/rendering,同时媒体播放将转到另一台设备。

Automatic Device Role Detection:

Consider a scenario in which a computer has a default rendering device, the speakers, and a default capture device, a microphone. The user connects a USB headset to the computer. After the appropriate drivers are installed, the operating system attempts to detect a role to assign for the new audio device.

并且,例如,

...The communication application can enhance user experience by implementing behaviors such as ducking by handling notifications from the device endpoint.

UPD

so only "ONE" role can be assigned

不正确,文档对此有明确的说明。

您所指的 API 允许您为特定角色获取默认设备。同一个设备可以同时默认为另一个角色。

让我再次从评论中摘录:"Roles help you choose between [multiple] devices instead." 角色对应用程序对音频设备的使用没有任何限制。他们只是在系统配备多个设备的情况下帮助选择合适的设备,并且可能还会对设备进行特定于角色的自定义,例如回声消除。