Color legend method
Forwards the Windows notifications about output devices to callbacks; the manager follows the default device with one.
A class. The mixing page shows it in context, with code.
Names are colored by what they are: a property, a method or an event; values and fields keep the plain color.
Methods
MmNotificationClient() →
MmNotificationClient(Action<string, DeviceState> onDeviceStateChangedCallback, Action<string> onDeviceRemovedCallback, Action<DataFlow, Role, string> onDefaultDeviceChangedCallback) · Creates a client that calls the three callbacks. They are called on a Windows audio thread and must return quickly.
| Parameter | Type | Description |
|---|---|---|
onDeviceStateChangedCallback |
Action<string, DeviceState> |
Gets the ID and the new state of a device whose state changes. |
onDeviceRemovedCallback |
Action<string> |
Gets the ID of a device that is removed. |
onDefaultDeviceChangedCallback |
Action<DataFlow, Role, string> |
Gets the data flow, the role and the ID of the new default device when a default device changes. |
Dispose() →
Dispose() · Stops listening.
OnDefaultDeviceChanged() →
OnDefaultDeviceChanged(DataFlow flow, Role role, string defaultDeviceId) · Calls the default device callback, for input and output devices and every role.
| Parameter | Type | Description |
|---|---|---|
flow |
DataFlow |
Whether the device plays (Render) or records (Capture). |
role |
Role |
The role it is the default device for: Console, Multimedia or Communications. |
defaultDeviceId |
string |
The ID of the new default device. |
OnDeviceAdded() →
OnDeviceAdded(string pwstrDeviceId) · Does nothing.
| Parameter | Type | Description |
|---|---|---|
pwstrDeviceId |
string |
The ID of the device added. |
OnDeviceRemoved() →
OnDeviceRemoved(string deviceId) · Calls the removal callback.
| Parameter | Type | Description |
|---|---|---|
deviceId |
string |
The ID of the device removed. |
OnDeviceStateChanged() →
OnDeviceStateChanged(string deviceId, DeviceState newState) · Calls the state callback. Called for every device whose state changes.
| Parameter | Type | Description |
|---|---|---|
deviceId |
string |
The ID of the device. |
newState |
DeviceState |
Its new state: Active, Disabled, NotPresent or Unplugged. |
OnPropertyValueChanged() →
OnPropertyValueChanged(string pwstrDeviceId, PropertyKey key) · Does nothing.
| Parameter | Type | Description |
|---|---|---|
pwstrDeviceId |
string |
The ID of the device. |
key |
PropertyKey |
The property whose value changed. |
RemoveDeviceEnumerator() →
RemoveDeviceEnumerator() · Stops listening. The enumerator is not disposed.
SetDeviceEnumerator() →
SetDeviceEnumerator(MMDeviceEnumerator deviceEnumerator) · Starts listening to the notifications of an NAudio device enumerator, and stops listening to the one before.
| Parameter | Type | Description |
|---|---|---|
deviceEnumerator |
MMDeviceEnumerator |
The enumerator to listen to; null only stops listening. |