Skip to content

Commit 7121ecb

Browse files
authored
fix(volume): Volume levels across dual-audio channels now kept for keep volume option (#1371)
1 parent b5e36cb commit 7121ecb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

SoundSwitch.Audio.Manager/AudioSwitcher.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ public void SetVolumeFromDefaultDevice(DeviceInfo device)
200200
var currentDefault = GetMmDefaultAudioEndpoint((EDataFlow)device.Type, ERole.eConsole);
201201
if (currentDefault == null)
202202
return;
203+
203204
var audioInfo = InteractWithMmDevice(currentDefault, mmDevice =>
204205
{
205206
var defaultDeviceAudioEndpointVolume = mmDevice.AudioEndpointVolume;
@@ -222,7 +223,15 @@ public void SetVolumeFromDefaultDevice(DeviceInfo device)
222223
if (mmDevice.AudioEndpointVolume == null)
223224
return nextDevice;
224225

225-
mmDevice.AudioEndpointVolume.MasterVolumeLevelScalar = audioInfo.Volume;
226+
if (mmDevice.AudioEndpointVolume.Channels.Count == 2)
227+
{
228+
mmDevice.AudioEndpointVolume.Channels[0].VolumeLevelScalar = audioInfo.Volume;
229+
mmDevice.AudioEndpointVolume.Channels[1].VolumeLevelScalar = audioInfo.Volume;
230+
}
231+
else
232+
{
233+
mmDevice.AudioEndpointVolume.MasterVolumeLevelScalar = audioInfo.Volume;
234+
}
226235
mmDevice.AudioEndpointVolume.Mute = audioInfo.IsMuted;
227236
return mmDevice;
228237
});

0 commit comments

Comments
 (0)