Skip to content

Commit

Permalink
add TRACE messages when selecting sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
radj307 committed Nov 12, 2023
1 parent 97dd4c3 commit 562de4e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion VolumeControl.CoreAudio/AudioSessionMultiSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Runtime.CompilerServices;
using VolumeControl.CoreAudio.Events;
using VolumeControl.CoreAudio.Interfaces;
using VolumeControl.Log;
using VolumeControl.TypeExtensions;

namespace VolumeControl.CoreAudio
Expand Down Expand Up @@ -223,19 +224,29 @@ private PreviewSessionIsSelectedEventArgs NotifyPreviewSessionIsSelected(AudioSe
#region Add/Remove SelectedSession
private void AddSelectedSession(AudioSession audioSession)
{
if (SelectedSessions.Contains(audioSession)) return;
if (SelectedSessions.Contains(audioSession))
{
FLog.Warning($"[{nameof(AudioSessionMultiSelector)}] Session \"{audioSession.Name}\" is already selected, but {nameof(AddSelectedSession)} was called again!");
return;
}

var hadSelectedSessions = HasSelectedSessions;
_selectedSessions.Add(audioSession);
if (!hadSelectedSessions) // there are selected sessions now
NotifyPropertyChanged(nameof(HasSelectedSessions));

if (FLog.FilterEventType(EventType.TRACE))
FLog.Trace($"[{nameof(AudioSessionMultiSelector)}] Session \"{audioSession.Name}\" was selected.");
}
private bool RemoveSelectedSession(AudioSession audioSession)
{
if (_selectedSessions.Remove(audioSession))
{
if (_selectedSessions.Count == 0) // there are not selected sessions anymore
NotifyPropertyChanged(nameof(HasSelectedSessions));

if (FLog.FilterEventType(EventType.TRACE))
FLog.Trace($"[{nameof(AudioSessionMultiSelector)}] Session \"{audioSession.Name}\" was deselected.");
return true;
}
return false;
Expand Down

0 comments on commit 562de4e

Please sign in to comment.