Skip to content

Commit eb0d986

Browse files
committed
fix(AudioSwitch): Don't log crashed when trying to switch application audio endpoint on Windows 7
Fixes SOUNDSWITCH-CZ
1 parent 9ccaffc commit eb0d986

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

SoundSwitch.Audio.Manager/Interop/Client/Extended/Factory/AudioPolicyConfigFactory.cs

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ internal sealed class AudioPolicyConfigFactory
99

1010
public static IAudioPolicyConfig Create()
1111
{
12+
if (Environment.OSVersion.Version.Major < 10)
13+
{
14+
return new UnsupportedAudioPolicyConfig();
15+
}
1216
if (Environment.OSVersion.Version.Build >= OS_21H2_VERSION)
1317
{
1418
return new Post21H2AudioPolicyConfig();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using SoundSwitch.Audio.Manager.Interop.Enum;
2+
using SoundSwitch.Audio.Manager.Interop.Interface.Policy.Extended;
3+
4+
namespace SoundSwitch.Audio.Manager.Interop.Client.Extended;
5+
6+
public class UnsupportedAudioPolicyConfig : IAudioPolicyConfig
7+
{
8+
public void SetPersistedDefaultAudioEndpoint(uint processId, EDataFlow flow, ERole role, string deviceId)
9+
{
10+
}
11+
12+
public string? GetPersistedDefaultAudioEndpoint(uint processId, EDataFlow flow, ERole role)
13+
{
14+
return null;
15+
}
16+
17+
public void ClearAllPersistedApplicationDefaultEndpoints()
18+
{
19+
}
20+
}

0 commit comments

Comments
 (0)