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

A single audio session running on an audio device. More...

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

Public Member Functions

override string ToString ()
 Gets the ProcessIdentifier associated with this AudioSession instance. More...
 
Process? GetProcess ()
 Gets the process that created this audio session. More...
 
TargetInfo GetTargetInfo ()
 Gets a new TargetInfo object representing this AudioSession instance. More...
 
bool HasMatchingName (string name, StringComparison stringComparison=StringComparison.Ordinal)
 Determines whether the specified name is equal to this instance's Name or ProcessName. More...
 
void Dispose ()
 

Static Public Member Functions

static bool TryParseProcessIdentifier (string processIdentifier, out uint? processId, out string? processName)
 Splits the given processIdentifier into its ProcessID & ProcessName components, and converts the ProcessID to an unsigned integer. More...
 

Static Public Attributes

const char ProcessIdentifierSeparatorChar = ':'
 The character that separates the PID & ProcessName components of ProcessIdentifier strings. More...
 
const char ProcessIdentifierInputChar = 'I'
 The character used in the process identifier to indicate that a session is a capture session. More...
 
const char ProcessIdentifierOutputChar = 'O'
 The character used in the process identifier to indicate that a session is a render session. More...
 
static ? uint processId
 Splits the given processIdentifier into its ProcessID and ProcessName components, if they exist. More...
 

Properties

AudioDevice AudioDevice [get]
 Gets the CoreAudio.AudioDevice that this AudioSession instance is running on. More...
 
AudioSessionControl2 AudioSessionControl [get]
 Gets the AudioSessionControl2 controller instance associated with this AudioSession instance. More...
 
DataFlow DataFlow [get]
 Gets the DataFlow direction of this audio session. More...
 
uint PID [get]
 Gets the process ID of the process associated with this AudioSession instance. More...
 
string ProcessName [get]
 Gets the Process Name of the process associated with this AudioSession instance. More...
 
string Name [get, set]
 Gets or sets the name of this AudioSession instance. More...
 
bool HasCustomName [get]
 Gets whether this session has a Name that differs from its ProcessName. More...
 
string ProcessIdentifier [get]
 Gets the process identifier of this audio session. More...
 
string SessionIdentifier [get]
 Gets the session identifier string from the windows API. More...
 
string SessionInstanceIdentifier [get]
 Gets the session instance identifier from the windows API. More...
 
float NativeVolume [get, set]
 
int Volume [get, set]
 
bool Mute [get, set]
 
float PeakMeterValue [get]
 
bool IsHidden [get, set]
 Gets or sets whether this session is hidden in the AudioSessionManager. More...
 
- Properties inherited from VolumeControl.CoreAudio.Interfaces.IAudioControl
float NativeVolume [get, set]
 Gets or sets the volume level of the audio instance, in the native float format. More...
 
int Volume [get, set]
 Gets or sets the volume level of the audio instance. More...
 
bool Mute [get, set]
 Gets or sets the mute state of the audio instance. More...
 
DataFlow DataFlow [get]
 Gets whether this audio control is a capture or render instance. More...
 
- Properties inherited from VolumeControl.CoreAudio.Interfaces.IReadOnlyAudioControl
float NativeVolume [get]
 Gets the volume level, in the native float format. More...
 
int Volume [get]
 Gets the volume level. More...
 
bool Mute [get]
 Gets the mute state. More...
 
DataFlow DataFlow [get]
 Gets whether this audio control is a capture or render instance. More...
 
- Properties inherited from VolumeControl.CoreAudio.Interfaces.IHideableAudioControl
bool IsHidden [get, set]
 Gets or sets whether this audio instance is hidden. More...
 
- Properties inherited from VolumeControl.CoreAudio.Interfaces.IAudioPeakMeter
float PeakMeterValue [get]
 The current peak meter value. More...
 

Events

PropertyChangedEventHandler? PropertyChanged
 
AudioSessionControl2.? SessionDisconnectedDelegate SessionDisconnected
 Occurs when this AudioSession instance has been disconnected. More...
 
EventHandler< AudioSessionState >? StateChanged
 Occurs when the state of this AudioSession instance was changed. More...
 
EventHandler< string >? DisplayNameChanged
 Occurs when the display name of this AudioSession instance has changed. More...
 
EventHandler< string >? IconPathChanged
 Occurs when the display icon path for this AudioSession instance has changed. More...
 
VolumeChangedEventHandler? VolumeChanged
 Occurs when the volume level or mute state of this AudioSession has changed. More...
 

Detailed Description

A single audio session running on an audio device.

Member Function Documentation

◆ GetProcess()

Process? VolumeControl.CoreAudio.AudioSession.GetProcess ( )

Gets the process that created this audio session.

The caller is responsible for calling Process.Dispose(bool).

Returns
System.Diagnostics.Process instance that created this audio session, or null if an error occurred.

References VolumeControl.Log.FLog.Error(), and VolumeControl.CoreAudio.AudioSession.PID.

Here is the call graph for this function:

◆ GetTargetInfo()

TargetInfo VolumeControl.CoreAudio.AudioSession.GetTargetInfo ( )

Gets a new TargetInfo object representing this AudioSession instance.

Returns
A TargetInfo struct that represents this AudioSession instance.

References VolumeControl.CoreAudio.AudioSession.PID, VolumeControl.CoreAudio.AudioSession.ProcessName, and VolumeControl.CoreAudio.AudioSession.SessionInstanceIdentifier.

◆ HasMatchingName()

bool VolumeControl.CoreAudio.AudioSession.HasMatchingName ( string  name,
StringComparison  stringComparison = StringComparison.Ordinal 
)

Determines whether the specified name is equal to this instance's Name or ProcessName.

Compares the specified name to the ProcessName property and also the Name property when HasCustomName is true.

Parameters
nameThe Name or ProcessName of an audio session.
stringComparisonSpecifies how strings will be compared.
Returns
true when the specified name matches this session; otherwise false.

Referenced by VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithName(), and VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithSimilarProcessIdentifier().

Here is the caller graph for this function:

◆ ToString()

override string VolumeControl.CoreAudio.AudioSession.ToString ( )

Gets the ProcessIdentifier associated with this AudioSession instance.

Returns
The ProcessIdentifier string for this AudioSession instance.

◆ TryParseProcessIdentifier()

static bool VolumeControl.CoreAudio.AudioSession.TryParseProcessIdentifier ( string  processIdentifier,
out uint?  processId,
out string?  processName 
)
static

Splits the given processIdentifier into its ProcessID & ProcessName components, and converts the ProcessID to an unsigned integer.

Parameters
processIdentifierA Process Identifier string. See ProcessIdentifier.
processIdThe ProcessID component of the processIdentifier when it contains one & the method returned true; otherwise null.
processNameThe ProcessName component of the processIdentifier when it contains one & the method returned true; otherwise null.
Returns
true when successful and no exceptions were thrown; otherwise false.

References VolumeControl.CoreAudio.AudioSession.processId.

Member Data Documentation

◆ processId

? uint VolumeControl.CoreAudio.AudioSession.processId
static

Splits the given processIdentifier into its ProcessID and ProcessName components, if they exist.

Parameters
processIdentifierA process identifier string.
Exceptions
ArgumentNullException
Exceptions
FormatException
Exceptions
OverflowException
Returns
A tuple containing the ProcessID and ProcessName components of the given processIdentifier , if found.

Referenced by VolumeControl.CoreAudio.AudioSession.TryParseProcessIdentifier().

◆ ProcessIdentifierInputChar

const char VolumeControl.CoreAudio.AudioSession.ProcessIdentifierInputChar = 'I'
static

The character used in the process identifier to indicate that a session is a capture session.

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

◆ ProcessIdentifierOutputChar

const char VolumeControl.CoreAudio.AudioSession.ProcessIdentifierOutputChar = 'O'
static

The character used in the process identifier to indicate that a session is a render session.

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

◆ ProcessIdentifierSeparatorChar

const char VolumeControl.CoreAudio.AudioSession.ProcessIdentifierSeparatorChar = ':'
static

The character that separates the PID & ProcessName components of ProcessIdentifier strings.

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

Property Documentation

◆ AudioDevice

AudioDevice VolumeControl.CoreAudio.AudioSession.AudioDevice
get

Gets the CoreAudio.AudioDevice that this AudioSession instance is running on.

◆ AudioSessionControl

AudioSessionControl2 VolumeControl.CoreAudio.AudioSession.AudioSessionControl
get

Gets the AudioSessionControl2 controller instance associated with this AudioSession instance.

Referenced by VolumeControl.CoreAudio.AudioSession.Dispose().

◆ DataFlow

DataFlow VolumeControl.CoreAudio.AudioSession.DataFlow
get

◆ HasCustomName

bool VolumeControl.CoreAudio.AudioSession.HasCustomName
get

Gets whether this session has a Name that differs from its ProcessName.

Returns
true when the Name is not the same as the ProcessName; otherwise false.

◆ IsHidden

bool VolumeControl.CoreAudio.AudioSession.IsHidden
getset

◆ Name

string VolumeControl.CoreAudio.AudioSession.Name
getset

Gets or sets the name of this AudioSession instance.

This defaults to the internal AudioSessionControl2.DisplayName if available, otherwise it defaults to the ProcessName.

◆ PID

uint VolumeControl.CoreAudio.AudioSession.PID
get

◆ ProcessIdentifier

string VolumeControl.CoreAudio.AudioSession.ProcessIdentifier
get

Gets the process identifier of this audio session.

Process Identifiers are composed of the PID and ProcessName of a session, separated by a colon.
Example: "1234:SomeProcess"

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

◆ ProcessName

string VolumeControl.CoreAudio.AudioSession.ProcessName
get

Gets the Process Name of the process associated with this AudioSession instance.

Referenced by VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithProcessName(), and VolumeControl.CoreAudio.AudioSession.GetTargetInfo().

◆ SessionIdentifier

string VolumeControl.CoreAudio.AudioSession.SessionIdentifier
get

Gets the session identifier string from the windows API.

Processes that create multiple audio sessions will create multiple AudioSession instances with identical SessionIdentifier strings. For an identifier that is unique across all audio sessions, use SessionInstanceIdentifier or ProcessIdentifier instead.

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

◆ SessionInstanceIdentifier

string VolumeControl.CoreAudio.AudioSession.SessionInstanceIdentifier
get

Gets the session instance identifier from the windows API.

Unlike the SessionIdentifier, each SessionInstanceIdentifier is guaranteed to be unique to this AudioSession instance.

Referenced by VolumeControl.CoreAudio.AudioSessionManager.FindSessionWithSessionInstanceIdentifier(), and VolumeControl.CoreAudio.AudioSession.GetTargetInfo().

Event Documentation

◆ DisplayNameChanged

EventHandler<string>? VolumeControl.CoreAudio.AudioSession.DisplayNameChanged

Occurs when the display name of this AudioSession instance has changed.

◆ IconPathChanged

EventHandler<string>? VolumeControl.CoreAudio.AudioSession.IconPathChanged

Occurs when the display icon path for this AudioSession instance has changed.

◆ SessionDisconnected

AudioSessionControl2.? SessionDisconnectedDelegate VolumeControl.CoreAudio.AudioSession.SessionDisconnected

Occurs when this AudioSession instance has been disconnected.

◆ StateChanged

EventHandler<AudioSessionState>? VolumeControl.CoreAudio.AudioSession.StateChanged

Occurs when the state of this AudioSession instance was changed.

◆ VolumeChanged

VolumeChangedEventHandler? VolumeControl.CoreAudio.AudioSession.VolumeChanged

Occurs when the volume level or mute state of this AudioSession has changed.


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