Skip to content

Commit

Permalink
fix audio session bugs
Browse files Browse the repository at this point in the history
- made Volume property setter not duplicate events
- made Volume property setter being linked to NativeVolume more clear
- actually triggered volume change events
  • Loading branch information
radj307 committed Nov 4, 2023
1 parent e65c416 commit f86f189
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions VolumeControl.CoreAudio/AudioSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ private set
/// Unlike the SessionIdentifier, each SessionInstanceIdentifier is guaranteed to be unique to this <see cref="AudioSession"/> instance.
/// </remarks>
public string SessionInstanceIdentifier => AudioSessionControl.SessionInstanceIdentifier;
#endregion Properties

#region IAudioControl Implementation
/// <inheritdoc/>
public float NativeVolume
{
Expand All @@ -183,22 +180,15 @@ public float NativeVolume
isNotifying = true;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(Volume));
NotifyVolumeChanged(value, Mute);
isNotifying = false;
}
}
/// <inheritdoc/>
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);
}
/// <inheritdoc/>
public bool Mute
Expand All @@ -208,9 +198,10 @@ public bool Mute
{
SimpleAudioVolume.Mute = value;
NotifyPropertyChanged();
NotifyVolumeChanged(NativeVolume, value);
}
}
#endregion IAudioControl Implementation
#endregion Properties

#region IVolumePeakMeter Implementation
/// <inheritdoc/>
Expand Down

0 comments on commit f86f189

Please sign in to comment.