Skip to content

Commit

Permalink
fix(volume): Volume levels across dual-audio channels now kept for ke…
Browse files Browse the repository at this point in the history
…ep volume option (#1371)
  • Loading branch information
XangelMusic authored Feb 1, 2024
1 parent b5e36cb commit 7121ecb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion SoundSwitch.Audio.Manager/AudioSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public void SetVolumeFromDefaultDevice(DeviceInfo device)
var currentDefault = GetMmDefaultAudioEndpoint((EDataFlow)device.Type, ERole.eConsole);
if (currentDefault == null)
return;

var audioInfo = InteractWithMmDevice(currentDefault, mmDevice =>
{
var defaultDeviceAudioEndpointVolume = mmDevice.AudioEndpointVolume;
Expand All @@ -222,7 +223,15 @@ public void SetVolumeFromDefaultDevice(DeviceInfo device)
if (mmDevice.AudioEndpointVolume == null)
return nextDevice;

mmDevice.AudioEndpointVolume.MasterVolumeLevelScalar = audioInfo.Volume;
if (mmDevice.AudioEndpointVolume.Channels.Count == 2)
{
mmDevice.AudioEndpointVolume.Channels[0].VolumeLevelScalar = audioInfo.Volume;
mmDevice.AudioEndpointVolume.Channels[1].VolumeLevelScalar = audioInfo.Volume;
}
else
{
mmDevice.AudioEndpointVolume.MasterVolumeLevelScalar = audioInfo.Volume;
}
mmDevice.AudioEndpointVolume.Mute = audioInfo.IsMuted;
return mmDevice;
});
Expand Down

0 comments on commit 7121ecb

Please sign in to comment.