From aed1bb045b42e301c639919758396c141e88b760 Mon Sep 17 00:00:00 2001 From: GIT-Desktop Date: Tue, 8 Sep 2020 02:13:53 +0800 Subject: [PATCH] Added null check for dispose --- .../Application/MaxMix/Services/Audio/AudioSession.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Desktop/Application/MaxMix/Services/Audio/AudioSession.cs b/Desktop/Application/MaxMix/Services/Audio/AudioSession.cs index 5bfbfb38..c9579a4a 100644 --- a/Desktop/Application/MaxMix/Services/Audio/AudioSession.cs +++ b/Desktop/Application/MaxMix/Services/Audio/AudioSession.cs @@ -151,10 +151,13 @@ private void OnStateChanged(object sender, AudioSessionStateChangedEventArgs e) #region IDisposable public void Dispose() { - _events.StateChanged -= OnStateChanged; - _events.SimpleVolumeChanged -= OnVolumeChanged; + if (_events != null) + { + _events.StateChanged -= OnStateChanged; + _events.SimpleVolumeChanged -= OnVolumeChanged; - Session.UnregisterAudioSessionNotification(_events); + Session.UnregisterAudioSessionNotification(_events); + } Session = null; _session2 = null; _simpleAudio = null;