From f86f189ec1507b5e6813ad7f45664ad9c2e24b6a Mon Sep 17 00:00:00 2001 From: radj307 Date: Fri, 3 Nov 2023 23:01:09 -0400 Subject: [PATCH] fix audio session bugs - made Volume property setter not duplicate events - made Volume property setter being linked to NativeVolume more clear - actually triggered volume change events --- VolumeControl.CoreAudio/AudioSession.cs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/VolumeControl.CoreAudio/AudioSession.cs b/VolumeControl.CoreAudio/AudioSession.cs index ef9af49d0..79cb7bf97 100644 --- a/VolumeControl.CoreAudio/AudioSession.cs +++ b/VolumeControl.CoreAudio/AudioSession.cs @@ -164,9 +164,6 @@ private set /// Unlike the SessionIdentifier, each SessionInstanceIdentifier is guaranteed to be unique to this instance. /// public string SessionInstanceIdentifier => AudioSessionControl.SessionInstanceIdentifier; - #endregion Properties - - #region IAudioControl Implementation /// public float NativeVolume { @@ -183,6 +180,7 @@ public float NativeVolume isNotifying = true; NotifyPropertyChanged(); NotifyPropertyChanged(nameof(Volume)); + NotifyVolumeChanged(value, Mute); isNotifying = false; } } @@ -190,15 +188,7 @@ public float NativeVolume public int Volume { get => VolumeLevelConverter.FromNativeVolume(NativeVolume); - set - { - NativeVolume = VolumeLevelConverter.ToNativeVolume(value); - if (isNotifying) return; //< don't duplicate propertychanged notifications - isNotifying = true; - NotifyPropertyChanged(); - NotifyPropertyChanged(nameof(NativeVolume)); - isNotifying = false; - } + set => NativeVolume = VolumeLevelConverter.ToNativeVolume(value); } /// public bool Mute @@ -208,9 +198,10 @@ public bool Mute { SimpleAudioVolume.Mute = value; NotifyPropertyChanged(); + NotifyVolumeChanged(NativeVolume, value); } } - #endregion IAudioControl Implementation + #endregion Properties #region IVolumePeakMeter Implementation ///