Volume Control
Application-specific hotkeys for Windows
VolumeControl.CoreAudio.AudioSessionManager Class Reference

Manages a list of AudioSession instances and their related events for any number of AudioDeviceSessionManager instances. More...

Inheritance diagram for VolumeControl.CoreAudio.AudioSessionManager:
Collaboration diagram for VolumeControl.CoreAudio.AudioSessionManager:

Public Member Functions

 AudioSessionManager ()
 Creates a new AudioSessionManager instance without any SessionManagers. More...
 
 AudioSessionManager (IEnumerable< AudioDeviceSessionManager > sessionManagers)
 Creates a new AudioSessionManager instance with the given sessionManagers . More...
 
AudioSessionFindSession (Func< AudioSession, bool > predicate, bool includeHiddenSessions=false)
 Finds an audio session using a predicate function. More...
 
AudioSessionFindSessionWithPID (uint processId, DataFlow? dataFlow, bool includeHiddenSessions=false)
 Finds the audio session whose owning process has the given processId . More...
 
AudioSessionFindSessionWithPID (uint processId, bool includeHiddenSessions=false)
 Finds the audio session whose owning process has the given processId . More...
 
AudioSessionFindSessionWithProcessName (string processName, StringComparison stringComparison=StringComparison.Ordinal, bool includeHiddenSessions=false)
 Finds the audio session whose owning process has the given processName . More...
 
AudioSessionFindSessionWithName (string sessionName, DataFlow? dataFlow, StringComparison stringComparison=StringComparison.Ordinal, bool includeHiddenSessions=false)
 Finds the audio session whose owning process has the given sessionName . More...
 
AudioSessionFindSessionWithName (string sessionName, StringComparison stringComparison=StringComparison.Ordinal, bool includeHiddenSessions=false)
 Finds the audio session whose owning process has the given sessionName . More...
 
AudioSessionFindSessionWithExactProcessIdentifier (string processIdentifier, StringComparison stringComparison=StringComparison.Ordinal, bool includeHiddenSessions=false)
 Finds the audio session with the given processIdentifier . More...
 
AudioSessionFindSessionWithSimilarProcessIdentifier (string processIdentifier, StringComparison stringComparison=StringComparison.OrdinalIgnoreCase, bool includeHiddenSessions=false)
 Finds the audio session that matches - or is very similar to - the given processIdentifier . More...
 
AudioSessionFindSessionWithSessionIdentifier (string sessionIdentifier, StringComparison stringComparison=StringComparison.Ordinal, bool includeHiddenSessions=false)
 Finds the first audio session with the specified sessionIdentifier . More...
 
AudioSessionFindSessionWithSessionInstanceIdentifier (string sessionInstanceIdentifier, StringComparison stringComparison=StringComparison.Ordinal, bool includeHiddenSessions=false)
 Finds the audio session with the specified sessionInstanceIdentifier . More...
 
bool AddSessionManager (AudioDeviceSessionManager sessionManager)
 Adds the given sessionManager to the SessionManagers list. More...
 
bool RemoveSessionManager (AudioDeviceSessionManager sessionManager)
 Removes the given sessionManager from the SessionManagers list. More...
 
void HideSession (AudioSession session)
 Hides the specified session by moving it from the Sessions list to the HiddenSessions list. More...
 
void UnhideSession (AudioSession session)
 Unhides the specified session by moving it from the HiddenSessions list to the Sessions list. More...
 
void Dispose ()
 

Properties

IReadOnlyList< AudioDeviceSessionManagerSessionManagers [get]
 Gets the list of AudioDeviceSessionManager instances currently being managed by this AudioSessionManager instance. More...
 
IReadOnlyList< AudioSessionSessions [get]
 Gets the list of AudioSession instances currently being managed by this AudioSessionManager instance. More...
 
IReadOnlyList< AudioSessionHiddenSessions [get]
 Gets the list of hidden AudioSession instances (AudioSession.IsHidden) currently being managed by this AudioSessionManager instance. More...
 

Events

PreviewSessionNameEventHandler? PreviewSessionName
 Occurs before an AudioSession is added to the Sessions list to get its initial name. More...
 
PreviewSessionIsHiddenEventHandler? PreviewSessionIsHidden
 Occurs before an AudioSession is added to the Sessions list to get its initial hidden state. More...
 
EventHandler< AudioSession >? AddingSessionToList
 Occurs prior to an AudioSession being added to the Sessions list for any reason. More...
 
EventHandler< AudioSession >? AddedSessionToList
 Occurs when an AudioSession is added to the Sessions list for any reason. More...
 
EventHandler< AudioSession >? RemovingSessionFromList
 Occurs prior to an AudioSession being removed from the Sessions list for any reason. More...
 
EventHandler< AudioSession >? RemovedSessionFromList
 Occurs when an AudioSession is removed from the Sessions list for any reason. More...
 
EventHandler< AudioSession >? AddingSessionToHiddenList
 Occurs prior to an AudioSession being added to the HiddenSessions list for any reason. More...
 
EventHandler< AudioSession >? AddedSessionToHiddenList
 Occurs when an AudioSession is added to the HiddenSessions list for any reason. More...
 
EventHandler< AudioSession >? RemovingSessionFromHiddenList
 Occurs prior to an AudioSession being removed from the HiddenSessions list for any reason. More...
 
EventHandler< AudioSession >? RemovedSessionFromHiddenList
 Occurs when an AudioSession is removed from the HiddenSessions list for any reason. More...
 
EventHandler< AudioDeviceSessionManager >? SessionManagerAddedToList
 Occurs when an AudioDeviceSessionManager is added to the SessionManagers list for any reason. More...
 
EventHandler< AudioDeviceSessionManager >? SessionManagerRemovedFromList
 Occurs when an AudioDeviceSessionManager is removed from the SessionManagers list for any reason. More...
 

Detailed Description

Manages a list of AudioSession instances and their related events for any number of AudioDeviceSessionManager instances.

AudioDeviceSessionManager instances can be retrieved from AudioDevice.SessionManager

Constructor & Destructor Documentation

◆ AudioSessionManager() [1/2]

VolumeControl.CoreAudio.AudioSessionManager.AudioSessionManager ( )

Creates a new AudioSessionManager instance without any SessionManagers.

◆ AudioSessionManager() [2/2]

VolumeControl.CoreAudio.AudioSessionManager.AudioSessionManager ( IEnumerable< AudioDeviceSessionManager sessionManagers)

Creates a new AudioSessionManager instance with the given sessionManagers .

Parameters
sessionManagersAny number of AudioDeviceSessionManager instances to add to the SessionManagers list.

References VolumeControl.CoreAudio.AudioSessionManager.AddSessionManager().

Here is the call graph for this function:

Member Function Documentation

◆ AddSessionManager()

bool VolumeControl.CoreAudio.AudioSessionManager.AddSessionManager ( AudioDeviceSessionManager  sessionManager)

Adds the given sessionManager to the SessionManagers list.

Parameters
sessionManagerA AudioDeviceSessionManager instance to add.
Returns
true when successful; otherwise false if the sessionManager is already in the list.

References VolumeControl.CoreAudio.AudioDeviceSessionManager.SessionAddedToList, VolumeControl.CoreAudio.AudioSessionManager.SessionManagers, and VolumeControl.CoreAudio.AudioDeviceSessionManager.SessionRemovedFromList.

Referenced by VolumeControl.CoreAudio.AudioSessionManager.AudioSessionManager().

Here is the caller graph for this function:

◆ FindSession()

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSession ( Func< AudioSession, bool >  predicate,
bool  includeHiddenSessions = false 
)

Finds an audio session using a predicate function.

Parameters
predicateA predicate delegate that accepts an AudioSession and returns true to indicate a match or false to continue.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
The first AudioSession instance that the predicate returned true for; otherwise null.

◆ FindSessionWithExactProcessIdentifier()

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithExactProcessIdentifier ( string  processIdentifier,
StringComparison  stringComparison = StringComparison.Ordinal,
bool  includeHiddenSessions = false 
)

Finds the audio session with the given processIdentifier .

Parameters
processIdentifierA Process Identifier to search for. See AudioSession.ProcessIdentifier.
stringComparisonThe StringComparison type to use when comparing process identifier strings.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
The AudioSession with the given processIdentifier if found; otherwise null.

References VolumeControl.CoreAudio.AudioSessionManager.HiddenSessions, VolumeControl.CoreAudio.AudioSession.ProcessIdentifier, and VolumeControl.CoreAudio.AudioSessionManager.Sessions.

◆ FindSessionWithName() [1/2]

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithName ( string  sessionName,
DataFlow?  dataFlow,
StringComparison  stringComparison = StringComparison.Ordinal,
bool  includeHiddenSessions = false 
)

Finds the audio session whose owning process has the given sessionName .

Parameters
sessionNameA Name or Process Name to search for. See AudioSession.Name & AudioSession.ProcessName.
dataFlowThe data flow type of the session to search for.
stringComparisonThe StringComparison type to use when comparing process name strings.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
The first AudioSession with the given sessionName if found; otherwise null.

References VolumeControl.CoreAudio.AudioSession.DataFlow, VolumeControl.CoreAudio.AudioSession.HasMatchingName(), VolumeControl.CoreAudio.AudioSessionManager.HiddenSessions, and VolumeControl.CoreAudio.AudioSessionManager.Sessions.

Referenced by VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithSimilarProcessIdentifier().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindSessionWithName() [2/2]

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithName ( string  sessionName,
StringComparison  stringComparison = StringComparison.Ordinal,
bool  includeHiddenSessions = false 
)

Finds the audio session whose owning process has the given sessionName .

Parameters
sessionNameA Name or Process Name to search for. See AudioSession.Name & AudioSession.ProcessName.
stringComparisonThe StringComparison type to use when comparing process name strings.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
The first AudioSession with the given sessionName if found; otherwise null.

References VolumeControl.CoreAudio.AudioSession.HasMatchingName(), VolumeControl.CoreAudio.AudioSessionManager.HiddenSessions, and VolumeControl.CoreAudio.AudioSessionManager.Sessions.

Here is the call graph for this function:

◆ FindSessionWithPID() [1/2]

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithPID ( uint  processId,
bool  includeHiddenSessions = false 
)

Finds the audio session whose owning process has the given processId .

Parameters
processIdA Process ID to search for. See AudioSession.PID.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
The AudioSession with the given processId if found; otherwise null.

References VolumeControl.CoreAudio.AudioSessionManager.HiddenSessions, VolumeControl.CoreAudio.AudioSession.PID, and VolumeControl.CoreAudio.AudioSessionManager.Sessions.

◆ FindSessionWithPID() [2/2]

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithPID ( uint  processId,
DataFlow?  dataFlow,
bool  includeHiddenSessions = false 
)

Finds the audio session whose owning process has the given processId .

Parameters
processIdA Process ID to search for. See AudioSession.PID.
dataFlowThe data flow type of the session to search for.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
The AudioSession with the given processId if found; otherwise null.

References VolumeControl.CoreAudio.AudioSession.DataFlow, VolumeControl.CoreAudio.AudioSessionManager.HiddenSessions, VolumeControl.CoreAudio.AudioSession.PID, and VolumeControl.CoreAudio.AudioSessionManager.Sessions.

Referenced by VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithSimilarProcessIdentifier().

Here is the caller graph for this function:

◆ FindSessionWithProcessName()

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithProcessName ( string  processName,
StringComparison  stringComparison = StringComparison.Ordinal,
bool  includeHiddenSessions = false 
)

Finds the audio session whose owning process has the given processName .

Note that this method checks ONLY the AudioSession.ProcessName property, which can differ from the name shown in the UI (AudioSession.Name)!
To check both properties, use FindSessionWithName(string, StringComparison, bool) instead.

Parameters
processNameA Process Name to search for. See AudioSession.ProcessName.
stringComparisonThe StringComparison type to use when comparing process name strings.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
The first AudioSession with the given processName if found; otherwise null.

References VolumeControl.CoreAudio.AudioSessionManager.HiddenSessions, VolumeControl.CoreAudio.AudioSession.ProcessName, and VolumeControl.CoreAudio.AudioSessionManager.Sessions.

◆ FindSessionWithSessionIdentifier()

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithSessionIdentifier ( string  sessionIdentifier,
StringComparison  stringComparison = StringComparison.Ordinal,
bool  includeHiddenSessions = false 
)

Finds the first audio session with the specified sessionIdentifier .

Parameters
sessionIdentifierA SessionIdentifier string to search for. See AudioSession.SessionIdentifier.
stringComparisonThe StringComparison type to use when comparing session identifier strings.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
The first AudioSession with the given sessionIdentifier if found; otherwise null.

References VolumeControl.CoreAudio.AudioSessionManager.HiddenSessions, VolumeControl.CoreAudio.AudioSession.SessionIdentifier, and VolumeControl.CoreAudio.AudioSessionManager.Sessions.

◆ FindSessionWithSessionInstanceIdentifier()

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithSessionInstanceIdentifier ( string  sessionInstanceIdentifier,
StringComparison  stringComparison = StringComparison.Ordinal,
bool  includeHiddenSessions = false 
)

Finds the audio session with the specified sessionInstanceIdentifier .

Parameters
sessionInstanceIdentifierA SessionInstanceIdentifier to search for. See AudioSession.SessionInstanceIdentifier.
stringComparisonThe StringComparison type to use when comparing session instance identifier strings.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
The AudioSession with the given sessionInstanceIdentifier if found; otherwise null.

References VolumeControl.CoreAudio.AudioSessionManager.HiddenSessions, VolumeControl.CoreAudio.AudioSession.SessionInstanceIdentifier, and VolumeControl.CoreAudio.AudioSessionManager.Sessions.

◆ FindSessionWithSimilarProcessIdentifier()

AudioSession? VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithSimilarProcessIdentifier ( string  processIdentifier,
StringComparison  stringComparison = StringComparison.OrdinalIgnoreCase,
bool  includeHiddenSessions = false 
)

Finds the audio session that matches - or is very similar to - the given processIdentifier .

When searching for text entered by the user, this method should always be used over the other FindSession... methods.

Parameters
processIdentifierA ProcessIdentifier to search for. See AudioSession.ProcessIdentifier.
Supports partial identifiers that only include the PID or ProcessName component, with or without the separator character.
stringComparisonThe StringComparison type to use when comparing strings.
includeHiddenSessionsWhen true, also searches the hidden sessions; otherwise when false, only searches through visible sessions.
Returns
An AudioSession that matches - or is similar to - the given processIdentifier if found; otherwise null.
The returned session can have a different PID than the one specified by the processIdentifier .

References VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithName(), VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithPID(), VolumeControl.CoreAudio.AudioSession.HasMatchingName(), VolumeControl.CoreAudio.AudioSession.ProcessIdentifierInputChar, VolumeControl.CoreAudio.AudioSession.ProcessIdentifierOutputChar, and VolumeControl.CoreAudio.AudioSession.ProcessIdentifierSeparatorChar.

Here is the call graph for this function:

◆ HideSession()

void VolumeControl.CoreAudio.AudioSessionManager.HideSession ( AudioSession  session)

Hides the specified session by moving it from the Sessions list to the HiddenSessions list.

Parameters
sessionThe AudioSession instance to hide.

References VolumeControl.CoreAudio.AudioSession.IsHidden.

◆ RemoveSessionManager()

bool VolumeControl.CoreAudio.AudioSessionManager.RemoveSessionManager ( AudioDeviceSessionManager  sessionManager)

Removes the given sessionManager from the SessionManagers list.

Parameters
sessionManagerA AudioDeviceSessionManager instance to remove.
Returns
true when successful; otherwise false when the sessionManager wasn't in the list.

References VolumeControl.CoreAudio.AudioDeviceSessionManager.SessionAddedToList, VolumeControl.CoreAudio.AudioSessionManager.SessionManagers, and VolumeControl.CoreAudio.AudioDeviceSessionManager.SessionRemovedFromList.

◆ UnhideSession()

void VolumeControl.CoreAudio.AudioSessionManager.UnhideSession ( AudioSession  session)

Unhides the specified session by moving it from the HiddenSessions list to the Sessions list.

Parameters
session

References VolumeControl.CoreAudio.AudioSession.IsHidden.

Property Documentation

◆ HiddenSessions

◆ SessionManagers

IReadOnlyList<AudioDeviceSessionManager> VolumeControl.CoreAudio.AudioSessionManager.SessionManagers
get

◆ Sessions

Event Documentation

◆ AddedSessionToHiddenList

EventHandler<AudioSession>? VolumeControl.CoreAudio.AudioSessionManager.AddedSessionToHiddenList

Occurs when an AudioSession is added to the HiddenSessions list for any reason.

◆ AddedSessionToList

EventHandler<AudioSession>? VolumeControl.CoreAudio.AudioSessionManager.AddedSessionToList

Occurs when an AudioSession is added to the Sessions list for any reason.

Referenced by VolumeControl.CoreAudio.AudioSessionMultiSelector.AudioSessionMultiSelector().

◆ AddingSessionToHiddenList

EventHandler<AudioSession>? VolumeControl.CoreAudio.AudioSessionManager.AddingSessionToHiddenList

Occurs prior to an AudioSession being added to the HiddenSessions list for any reason.

◆ AddingSessionToList

EventHandler<AudioSession>? VolumeControl.CoreAudio.AudioSessionManager.AddingSessionToList

Occurs prior to an AudioSession being added to the Sessions list for any reason.

◆ PreviewSessionIsHidden

PreviewSessionIsHiddenEventHandler? VolumeControl.CoreAudio.AudioSessionManager.PreviewSessionIsHidden

Occurs before an AudioSession is added to the Sessions list to get its initial hidden state.

This allows handler methods to set whether the audio session is hidden by default.

◆ PreviewSessionName

PreviewSessionNameEventHandler? VolumeControl.CoreAudio.AudioSessionManager.PreviewSessionName

Occurs before an AudioSession is added to the Sessions list to get its initial name.

This allows the name of the audio session to be changed by setting the PreviewSessionNameEventArgs.SessionName property in a handler method.

◆ RemovedSessionFromHiddenList

EventHandler<AudioSession>? VolumeControl.CoreAudio.AudioSessionManager.RemovedSessionFromHiddenList

Occurs when an AudioSession is removed from the HiddenSessions list for any reason.

◆ RemovedSessionFromList

EventHandler<AudioSession>? VolumeControl.CoreAudio.AudioSessionManager.RemovedSessionFromList

Occurs when an AudioSession is removed from the Sessions list for any reason.

Referenced by VolumeControl.CoreAudio.AudioSessionSelector.AudioSessionSelector().

◆ RemovingSessionFromHiddenList

EventHandler<AudioSession>? VolumeControl.CoreAudio.AudioSessionManager.RemovingSessionFromHiddenList

Occurs prior to an AudioSession being removed from the HiddenSessions list for any reason.

◆ RemovingSessionFromList

EventHandler<AudioSession>? VolumeControl.CoreAudio.AudioSessionManager.RemovingSessionFromList

Occurs prior to an AudioSession being removed from the Sessions list for any reason.

Referenced by VolumeControl.CoreAudio.AudioSessionMultiSelector.AudioSessionMultiSelector().

◆ SessionManagerAddedToList

EventHandler<AudioDeviceSessionManager>? VolumeControl.CoreAudio.AudioSessionManager.SessionManagerAddedToList

Occurs when an AudioDeviceSessionManager is added to the SessionManagers list for any reason.

◆ SessionManagerRemovedFromList

EventHandler<AudioDeviceSessionManager>? VolumeControl.CoreAudio.AudioSessionManager.SessionManagerRemovedFromList

Occurs when an AudioDeviceSessionManager is removed from the SessionManagers list for any reason.


The documentation for this class was generated from the following file: