From 40db2ef44ffe0b667a666119ec1bd1c7f80e86d3 Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Sun, 5 Sep 2021 10:32:18 -0400 Subject: [PATCH] fix(Device::Volume): Only get volume when device is active --- SoundSwitch.Common/Framework/Audio/Device/DeviceFullInfo.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SoundSwitch.Common/Framework/Audio/Device/DeviceFullInfo.cs b/SoundSwitch.Common/Framework/Audio/Device/DeviceFullInfo.cs index 535683b416..e585e11ad4 100644 --- a/SoundSwitch.Common/Framework/Audio/Device/DeviceFullInfo.cs +++ b/SoundSwitch.Common/Framework/Audio/Device/DeviceFullInfo.cs @@ -28,7 +28,11 @@ public DeviceFullInfo(MMDevice device) : base(device) State = device.State; try { - Volume = (int)(device.AudioEndpointVolume.MasterVolumeLevelScalar * 100); + //Can only get volume for active devices + if (device.State == DeviceState.Active) + { + Volume = (int)(device.AudioEndpointVolume.MasterVolumeLevelScalar * 100); + } } catch {