From 41fc905e8c86f70f7d5eb0f95a279ef9a5f7c70c Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Mon, 7 Dec 2020 21:11:51 +1300 Subject: [PATCH] Skip audio change if same audio device Only perform an audio device change if the audio device is a different one. --- DisplayMagician/ShortcutRepository.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index f1f0966..cabafb9 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -447,8 +447,12 @@ namespace DisplayMagician } // record the old audio device + bool needToChangeAudio = false; CoreAudioDevice rollbackAudioDevice = _audioController.DefaultPlaybackDevice; double rollbackAudioVolume = _audioController.DefaultPlaybackDevice.Volume; + if (!rollbackAudioDevice.FullName.Equals(shortcutToUse.AudioDevice)) + needToChangeAudio = true; + // Change Audio Device (if one specified) if (shortcutToUse.ChangeAudioDevice) @@ -835,7 +839,7 @@ namespace DisplayMagician } // Change Audio Device back (if one specified) - if (shortcutToUse.ChangeAudioDevice) + if (needToChangeAudio) { // use the Audio Device rollbackAudioDevice.SetAsDefault();