From the Microsoft API doc: https://learn.microsoft.com/en-us/windows/win32/api/mmdeviceapi/ne-mmdeviceapi-erole
The ERole
enum
typedef enum __MIDL___MIDL_itf_mmdeviceapi_0000_0000_0002 {
eConsole,
eMultimedia,
eCommunications,
ERole_enum_count
} ERole;
defines a list of "roles" that audio endpoint devices choose to play
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).
What I don't get from the doc page is:
eConsole
, will it be completely excluded from handling
Music, movies, narration, and live music recording, plus
Voice communications (talking to another person)
?
I don't believe the answer is yes, because the low-level hardware or the OS wouldn't know whether an audio stream is music or speech without user tagging. So what is this ERole
then? An audio mixing configuration that plays "well" (subjectively and statistically) with the target content types? A latency setting? or a combination of the two or more properties?
UPDATE
Thanks for @Roman R.'s answer. Now more questions still fitting the question title:
Doc of IMMDeviceEnumerator::GetDefaultAudioEndpoint
says:
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
so only "ONE" role can be assigned; And since ERole_enum_count
is not a real option as in most enum custom protocols, how would one make sure "all of the roles
" be played by a single device, as mentioned in the Device Roles and your quote on that page?
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.
The first sentence above answers the question if roles are mutually exclusive. Devices are not excluded from handling audio I/O. Instead the roles define which device is used for specific activity in a system with multiple devices. For example, a communication software would do audio capture/rendering using devices set to role eCommunications
while in the same time media playback would go to another device.
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.
and, as an example,
...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
Not true, and the documentation has a clear statement on that.
The API you are referring to allows you to get default device for specific role. The same device can be default for another role in the same time.
Let me pull this one from comment once again: "Roles help you choose between [multiple] devices instead." Roles put no constraint on applications' use of audio devices. They just help to pick proper device in the case the system is equipped with several, and than there might be also role-specific customizations for the devices, think for example of echo cancellation.