Interface IAudioSessionEvents
- Namespace
- AudioDeviceLib.CoreAudioApi
- Assembly
- AudioDeviceLib.dll
Receives change notifications for a single audio session. Implement this and pass the instance to RegisterAudioSessionNotification(IAudioSessionEvents).
public interface IAudioSessionEvents
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.
The session parameter passed to every method is an immutable AudioSessionInfo
snapshot of the session the notification came from, so a single consumer registered on several
sessions can tell them apart. It is a point-in-time copy (identifiers, display name, icon path,
state), never the live COM object, so nothing you do with it can reenter Core Audio while it is
dispatching.
Methods
OnChannelVolumeChanged(AudioSessionInfo, float[], uint, Guid?)
Called when one or more per-channel volumes change.
void OnChannelVolumeChanged(AudioSessionInfo session, float[] newChannelVolumes, uint changedChannel, Guid? eventContext)
Parameters
sessionAudioSessionInfoImmutable snapshot identifying the session that raised the notification.
newChannelVolumesfloat[]The new per-channel volume scalars (one entry per channel).
changedChanneluintThe index of the channel that changed, or 0xFFFFFFFF if multiple changed.
eventContextGuid?The context GUID supplied by the caller that made the change, or null if that caller supplied none.
Remarks
Called on an arbitrary, non-UI thread.
OnDisplayNameChanged(AudioSessionInfo, string, Guid?)
Called when the session display name changes.
void OnDisplayNameChanged(AudioSessionInfo session, string newDisplayName, Guid? eventContext)
Parameters
sessionAudioSessionInfoImmutable snapshot identifying the session that raised the notification.
newDisplayNamestringThe new display name.
eventContextGuid?The context GUID supplied by the caller that made the change, or null if that caller supplied none.
Remarks
Called on an arbitrary, non-UI thread.
OnGroupingParamChanged(AudioSessionInfo, Guid, Guid?)
Called when the session grouping parameter changes.
void OnGroupingParamChanged(AudioSessionInfo session, Guid newGroupingParam, Guid? eventContext)
Parameters
sessionAudioSessionInfoImmutable snapshot identifying the session that raised the notification.
newGroupingParamGuidThe new grouping parameter GUID.
eventContextGuid?The context GUID supplied by the caller that made the change, or null if that caller supplied none.
Remarks
Called on an arbitrary, non-UI thread.
OnIconPathChanged(AudioSessionInfo, string, Guid?)
Called when the session icon path changes.
void OnIconPathChanged(AudioSessionInfo session, string newIconPath, Guid? eventContext)
Parameters
sessionAudioSessionInfoImmutable snapshot identifying the session that raised the notification.
newIconPathstringThe new icon path.
eventContextGuid?The context GUID supplied by the caller that made the change, or null if that caller supplied none.
Remarks
Called on an arbitrary, non-UI thread.
OnSessionDisconnected(AudioSessionBaseInfo, AudioSessionDisconnectReason)
Called when the session is disconnected from its audio device.
void OnSessionDisconnected(AudioSessionBaseInfo session, AudioSessionDisconnectReason disconnectReason)
Parameters
sessionAudioSessionBaseInfoImmutable snapshot identifying the session that raised the notification.
disconnectReasonAudioSessionDisconnectReasonThe reason the session was disconnected.
Remarks
Called on an arbitrary, non-UI thread.
OnSimpleVolumeChanged(AudioSessionInfo, float, bool, Guid?)
Called when the session master volume or mute state changes.
void OnSimpleVolumeChanged(AudioSessionInfo session, float newVolume, bool newMute, Guid? eventContext)
Parameters
sessionAudioSessionInfoImmutable snapshot identifying the session that raised the notification.
newVolumefloatThe new master volume scalar in the range 0.0 to 1.0.
newMuteboolThe new mute state.
eventContextGuid?The context GUID supplied by the caller that made the change, or null if that caller supplied none.
Remarks
Called on an arbitrary, non-UI thread.
OnStateChanged(AudioSessionInfo, AudioSessionState)
Called when the session activity state changes.
void OnStateChanged(AudioSessionInfo session, AudioSessionState newState)
Parameters
sessionAudioSessionInfoImmutable snapshot identifying the session that raised the notification.
newStateAudioSessionStateThe new session state.
Remarks
Called on an arbitrary, non-UI thread.