Skip to content

Commit

Permalink
fix(Device::Volume): Only get volume when device is active
Browse files Browse the repository at this point in the history
  • Loading branch information
Belphemur committed Sep 5, 2021
1 parent 5ae150b commit 40db2ef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion SoundSwitch.Common/Framework/Audio/Device/DeviceFullInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 40db2ef

Please sign in to comment.