Interface IAudioDeviceEvents
- Namespace
- AudioDeviceLib.CoreAudioApi
- Assembly
- AudioDeviceLib.dll
Receives change notifications for the set of audio endpoints. Implement this and register it with RegisterDeviceNotification(IAudioDeviceEvents).
public interface IAudioDeviceEvents
Remarks
THREADING: these callbacks are raised by Windows Core Audio on arbitrary, non-UI threads, and may arrive concurrently. Keep every method fast and non-blocking, do your own synchronization when touching shared state, and marshal to a UI thread yourself if you need to update UI. Exceptions thrown from a callback are converted to an HRESULT and returned to the audio engine; prefer handling errors inside the callback.
Do NOT register/unregister notifications or dispose the AudioController from inside a callback - that reenters Core Audio while it is dispatching. The payload is plain data (endpoint ID strings and enums), so there is no live COM object to misuse.
Methods
OnDefaultDeviceChanged(DataFlow, Role, string)
Called when the default endpoint changes for a given data flow and role.
void OnDefaultDeviceChanged(DataFlow flow, Role role, string defaultDeviceId)
Parameters
flowDataFlowThe data-flow direction whose default changed (Render or Capture).
roleRoleThe role whose default changed - for example Communications distinguishes a change to the default communications device from the console/multimedia default.
defaultDeviceIdstringThe endpoint ID of the new default device, or
nullwhen there is no longer a default for this flow/role (e.g. the last matching device was removed).
Remarks
Called on an arbitrary, non-UI thread.
OnDeviceAdded(string)
Called when a new endpoint is added.
void OnDeviceAdded(string deviceId)
Parameters
deviceIdstringThe endpoint ID of the added device.
Remarks
Called on an arbitrary, non-UI thread.
OnDeviceRemoved(string)
Called when an endpoint is removed.
void OnDeviceRemoved(string deviceId)
Parameters
deviceIdstringThe endpoint ID of the removed device.
Remarks
Called on an arbitrary, non-UI thread.
OnDeviceStateChanged(string, DeviceState)
Called when an endpoint's state changes (active, disabled, not present or unplugged).
void OnDeviceStateChanged(string deviceId, DeviceState newState)
Parameters
deviceIdstringThe endpoint ID of the device whose state changed.
newStateDeviceStateThe new device state reported by the system.
Remarks
Called on an arbitrary, non-UI thread.
OnPropertyValueChanged(string, PropertyKey)
Called when a property value of an endpoint changes.
void OnPropertyValueChanged(string deviceId, PropertyKey key)
Parameters
deviceIdstringThe endpoint ID of the device whose property changed.
keyPropertyKeyThe property that changed. Use Name for a friendly name of the property.
Remarks
Called on an arbitrary, non-UI thread.