Table of Contents

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

session AudioSessionInfo

Immutable snapshot identifying the session that raised the notification.

newChannelVolumes float[]

The new per-channel volume scalars (one entry per channel).

changedChannel uint

The index of the channel that changed, or 0xFFFFFFFF if multiple changed.

eventContext Guid?

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

session AudioSessionInfo

Immutable snapshot identifying the session that raised the notification.

newDisplayName string

The new display name.

eventContext Guid?

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

session AudioSessionInfo

Immutable snapshot identifying the session that raised the notification.

newGroupingParam Guid

The new grouping parameter GUID.

eventContext Guid?

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

session AudioSessionInfo

Immutable snapshot identifying the session that raised the notification.

newIconPath string

The new icon path.

eventContext Guid?

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

session AudioSessionBaseInfo

Immutable snapshot identifying the session that raised the notification.

disconnectReason AudioSessionDisconnectReason

The 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

session AudioSessionInfo

Immutable snapshot identifying the session that raised the notification.

newVolume float

The new master volume scalar in the range 0.0 to 1.0.

newMute bool

The new mute state.

eventContext Guid?

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

session AudioSessionInfo

Immutable snapshot identifying the session that raised the notification.

newState AudioSessionState

The new session state.

Remarks

Called on an arbitrary, non-UI thread.