Skip to content

Commit

Permalink
implement #88
Browse files Browse the repository at this point in the history
  • Loading branch information
radj307 committed Oct 12, 2023
1 parent 959a128 commit 88ed96d
Show file tree
Hide file tree
Showing 17 changed files with 626 additions and 271 deletions.
4 changes: 4 additions & 0 deletions VolumeControl.Core/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ private void PropertyWithCollectionChangedEvents_CollectionChanged(object? sende
/// </summary>
public TargetInfo TargetSession { get; set; } = TargetInfo.Empty;
/// <summary>
/// Gets or sets the list of selected sessions.
/// </summary>
public ObservableImmutableList<TargetInfo> SelectedSessions { get; set; } = new();
/// <summary>
/// Gets or sets whether the target session is locked.
/// </summary>
public bool LockTargetSession { get; set; } = false;
Expand Down
2 changes: 1 addition & 1 deletion VolumeControl.Core/HotkeyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ private void RecheckAllSelected()
{
bool prev = this.Hotkeys.First().Registered;
bool fullLoop = true;
for (int i = 1; i < this.Hotkeys.Count; ++i)
for (int i = 1, max = this.Hotkeys.Count; i < max; ++i)
{
if (this.Hotkeys[i].Registered != prev)
{
Expand Down
24 changes: 12 additions & 12 deletions VolumeControl.CoreAudio/AudioSessionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ private PreviewSessionIsHiddenEventArgs NotifyPreviewSessionIsHidden(AudioSessio
/// <returns>The <see cref="AudioSession"/> with the given <paramref name="processId"/> if found; otherwise <see langword="null"/>.</returns>
public AudioSession? FindSessionWithPID(uint processId, bool includeHiddenSessions = false)
{ // don't use FindSession here, this way is more than 2x faster:
for (int i = 0; i < Sessions.Count; ++i)
for (int i = 0, max = Sessions.Count; i < max; ++i)
{
AudioSession session = Sessions[i];
if (session.PID == processId) return session;
}
if (includeHiddenSessions)
{
for (int i = 0; i < HiddenSessions.Count; ++i)
for (int i = 0, max = HiddenSessions.Count; i < max; ++i)
{
AudioSession session = HiddenSessions[i];
if (session.PID == processId) return session;
Expand All @@ -205,14 +205,14 @@ private PreviewSessionIsHiddenEventArgs NotifyPreviewSessionIsHidden(AudioSessio
{
if (processName.Length == 0) return null;

for (int i = 0; i < Sessions.Count; ++i)
for (int i = 0, max = Sessions.Count; i < max; ++i)
{
AudioSession session = Sessions[i];
if (session.ProcessName.Equals(processName, stringComparison)) return session;
}
if (includeHiddenSessions)
{
for (int i = 0; i < HiddenSessions.Count; ++i)
for (int i = 0, max = HiddenSessions.Count; i < max; ++i)
{
AudioSession session = HiddenSessions[i];
if (session.ProcessName.Equals(processName, stringComparison)) return session;
Expand All @@ -234,15 +234,15 @@ private PreviewSessionIsHiddenEventArgs NotifyPreviewSessionIsHidden(AudioSessio
{
if (sessionName.Length == 0) return null;

for (int i = 0; i < Sessions.Count; ++i)
for (int i = 0, max = Sessions.Count; i < max; ++i)
{
AudioSession session = Sessions[i];
if (session.HasMatchingName(sessionName, stringComparison))
return session;
}
if (includeHiddenSessions)
{
for (int i = 0; i < HiddenSessions.Count; ++i)
for (int i = 0, max = HiddenSessions.Count; i < max; ++i)
{
AudioSession session = HiddenSessions[i];
if (session.HasMatchingName(sessionName, stringComparison))
Expand All @@ -265,14 +265,14 @@ private PreviewSessionIsHiddenEventArgs NotifyPreviewSessionIsHidden(AudioSessio
{
if (processIdentifier.Length == 0) return null;

for (int i = 0; i < Sessions.Count; ++i)
for (int i = 0, max = Sessions.Count; i < max; ++i)
{
AudioSession session = Sessions[i];
if (session.ProcessIdentifier.Equals(processIdentifier, stringComparison)) return session;
}
if (includeHiddenSessions)
{
for (int i = 0; i < HiddenSessions.Count; ++i)
for (int i = 0, max = HiddenSessions.Count; i < max; ++i)
{
AudioSession session = HiddenSessions[i];
if (session.ProcessIdentifier.Equals(processIdentifier, stringComparison)) return session;
Expand Down Expand Up @@ -343,14 +343,14 @@ private PreviewSessionIsHiddenEventArgs NotifyPreviewSessionIsHidden(AudioSessio
{
if (sessionIdentifier.Length == 0) return null;

for (int i = 0; i < Sessions.Count; ++i)
for (int i = 0, max = Sessions.Count; i < max; ++i)
{
AudioSession session = Sessions[i];
if (session.SessionIdentifier.Equals(sessionIdentifier, stringComparison)) return session;
}
if (includeHiddenSessions)
{
for (int i = 0; i < HiddenSessions.Count; ++i)
for (int i = 0, max = HiddenSessions.Count; i < max; ++i)
{
AudioSession session = HiddenSessions[i];
if (session.SessionIdentifier.Equals(sessionIdentifier, stringComparison)) return session;
Expand All @@ -372,14 +372,14 @@ private PreviewSessionIsHiddenEventArgs NotifyPreviewSessionIsHidden(AudioSessio
{
if (sessionInstanceIdentifier.Length == 0) return null;

for (int i = 0; i < Sessions.Count; ++i)
for (int i = 0, max = Sessions.Count; i < max; ++i)
{
AudioSession session = Sessions[i];
if (session.SessionInstanceIdentifier.Equals(sessionInstanceIdentifier, stringComparison)) return session;
}
if (includeHiddenSessions)
{
for (int i = 0; i < HiddenSessions.Count; ++i)
for (int i = 0, max = HiddenSessions.Count; i < max; ++i)
{
AudioSession session = HiddenSessions[i];
if (session.SessionInstanceIdentifier.Equals(sessionInstanceIdentifier, stringComparison)) return session;
Expand Down
Loading

0 comments on commit 88ed96d

Please sign in to comment.