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

标签 windows audio wasapi

来自 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;

定义音频端点设备选择播放的“角色”列表

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).


我没有从文档页面得到的是:
  • 如果设备设置为 eConsole , 会完全排除在处理
  • 之外吗?

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

    • Voice communications (talking to another person)



    ?

    我不相信答案是肯定的,因为低级硬件或操作系统不知道没有用户标记的音频流是音乐还是语音。那么这是什么ERole然后?与目标内容类型“良好”(主观和统计)播放的音频混合配置?延迟设置?还是两个或多个属性的组合?

    更新

    感谢@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在大多数枚举自定义协议(protocol)中不是一个真正的选择,如何确保“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 之外。相反,角色定义了哪个设备用于具有多个设备的系统中的特定事件。例如,通信软件将使用设置为角色 eCommunications 的设备进行音频捕获/渲染。同时媒体播放将转到另一台设备。

    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 允许您获取特定角色的默认设备。同一设备可以同时默认为另一个角色。

    让我再次从评论中删除这个:“角色可以帮助您在 [多个] 设备之间进行选择。”角色对应用程序使用音频设备没有任何限制。它们只是在系统配备多个设备的情况下帮助选择合适的设备,并且可能还有针对设备的角色特定定制,例如回声消除。

    关于windows - Windows 核心音频 API 中的 ERoles 枚举值代表什么?它们是相互排斥的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58073231/

    相关文章:

    windows - 在没有 forfiles 的情况下删除 X 天前的文件

    python - 如何向已注册的 COM 服务器添加新方法?

    c++ - Windows 7(或更高版本)中事件可见 HWND 的数量是否会显着影响性能?

    c# - 从Windows中的立体声混音中获取声音样本

    python - 采样音频不保留波(矢量)!

    winapi - 渲染音频流(WASAPI/WINAPI)

    c++ - 使用 WASAPI 录制音频流

    windows - 是否可以合理地绕过扫描工作目录的防病毒软件?

    iphone - 在 iOS 应用程序中播放多种声音(mp3、wav 等)

    c++ - 如何测试 Audio Session 的相等性