Skip to content

Commit ed6b92a

Browse files
committed
fix(AudioSwitcher): Fix switching audio device on Windows 11 with "Also foreground app"
Add missing methods for CSWinRT to be able to interact with the AudioPolicyClient Fixes #802
1 parent bbc1cb9 commit ed6b92a

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

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

+12-8
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,20 @@ internal static class AudioPolicyConfigFactory
99

1010
public static IAudioPolicyConfig Create()
1111
{
12-
if (Environment.OSVersion.Version.Major < 10)
12+
return Com.Threading.ComThread.Invoke<IAudioPolicyConfig>(() =>
1313
{
14-
return new UnsupportedAudioPolicyConfig();
15-
}
16-
if (Environment.OSVersion.Version.Build >= OS_21H2_VERSION)
17-
{
18-
return new Post21H2AudioPolicyConfig();
19-
}
14+
if (Environment.OSVersion.Version.Major < 10)
15+
{
16+
return new UnsupportedAudioPolicyConfig();
17+
}
18+
19+
if (Environment.OSVersion.Version.Build >= OS_21H2_VERSION)
20+
{
21+
return new Post21H2AudioPolicyConfig();
22+
}
2023

21-
return new Pre21H2AudioPolicyConfig();
24+
return new Pre21H2AudioPolicyConfig();
25+
});
2226
}
2327
}
2428
}

SoundSwitch.Audio.Manager/Interop/Interface/Policy/Extended/IAudioPolicyConfigFactoryNative.cs

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ namespace SoundSwitch.Audio.Manager.Interop.Interface.Policy.Extended
1010
[ComImport]
1111
public interface IAudioPolicyConfigFactoryVariant21H2Windows11
1212
{
13+
void GetIids(out int iidCount, out IntPtr iids);
14+
void GetRuntimeClassName(out IntPtr className);
15+
void GetTrustLevel(out WinRT.TrustLevel trustLevel);
16+
1317
int __incomplete__add_CtxVolumeChange();
1418
int __incomplete__remove_CtxVolumeChanged();
1519
int __incomplete__add_RingerVibrateStateChanged();

0 commit comments

Comments
 (0)