diff --git a/AudioDevice.cs b/AudioDevice.cs index 76aebb3..d782a18 100644 --- a/AudioDevice.cs +++ b/AudioDevice.cs @@ -4,7 +4,6 @@ using Serilog; using System; using System.Collections.Generic; using System.Linq; -using System.Windows.Threading; namespace WorkIndicator; @@ -14,6 +13,8 @@ internal class AudioDevice : IAudioSessionEventsHandler private readonly string _friendlyName; private readonly Dictionary _sessions = new(); + private bool _muted; + public delegate void AudioSessionsChangedDelegate(); public event AudioSessionsChangedDelegate AudioSessionsChanged; @@ -23,6 +24,9 @@ internal class AudioDevice : IAudioSessionEventsHandler _logger = Log.ForContext(); _friendlyName = device.DeviceFriendlyName; + _muted = device.AudioEndpointVolume.Mute; + + _logger.Information("AudioDevice: {name} {muted}", _friendlyName, _muted); device.AudioEndpointVolume.OnVolumeNotification += AudioEndpointVolume_OnVolumeNotification; device.AudioSessionManager.AudioSessionControl.RegisterEventClient(this); @@ -40,6 +44,8 @@ internal class AudioDevice : IAudioSessionEventsHandler private void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data) { _logger.Information("AudioEndpointVolume_OnVolumeNotification: {name} {muted}", _friendlyName, data.Muted); + + _muted = data.Muted; } private void AudioSessionManager_OnSessionCreated(object sender, IAudioSessionControl newSession)