diff --git a/src/BizHawk.Bizware.DirectX/IndirectX.cs b/src/BizHawk.Bizware.DirectX/IndirectX.cs
new file mode 100644
index 0000000000..3133b93c11
--- /dev/null
+++ b/src/BizHawk.Bizware.DirectX/IndirectX.cs
@@ -0,0 +1,29 @@
+#nullable enable
+
+using System;
+using System.Collections.Generic;
+
+using BizHawk.Bizware.BizwareGL;
+using BizHawk.Client.Common;
+
+namespace BizHawk.Bizware.DirectX
+{
+ /// An indirection, so that types from the SlimDX assembly don't need to be resolved if DirectX/XAudio2 features are never used.
+ public static class IndirectX
+ {
+ public static IGL CreateD3DGLImpl()
+ => new IGL_SlimDX9();
+
+ public static ISoundOutput CreateDSSoundOutput(IHostAudioManager sound, IntPtr mainWindowHandle, string chosenDeviceName)
+ => new DirectSoundSoundOutput(sound, mainWindowHandle, chosenDeviceName);
+
+ public static ISoundOutput CreateXAudio2SoundOutput(IHostAudioManager sound, string chosenDeviceName)
+ => new XAudio2SoundOutput(sound, chosenDeviceName);
+
+ public static IEnumerable GetDSSinkNames()
+ => DirectSoundSoundOutput.GetDeviceNames();
+
+ public static IEnumerable GetXAudio2SinkNames()
+ => XAudio2SoundOutput.GetDeviceNames();
+ }
+}
diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs
index 0cd6e1fe43..5e8f35acfd 100644
--- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs
+++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs
@@ -900,8 +900,8 @@ namespace BizHawk.Client.EmuHawk
{
static IEnumerable GetDeviceNamesCallback(ESoundOutputMethod outputMethod) => outputMethod switch
{
- ESoundOutputMethod.DirectSound => DirectSoundSoundOutput.GetDeviceNames(),
- ESoundOutputMethod.XAudio2 => XAudio2SoundOutput.GetDeviceNames(),
+ ESoundOutputMethod.DirectSound => IndirectX.GetDSSinkNames(),
+ ESoundOutputMethod.XAudio2 => IndirectX.GetXAudio2SinkNames(),
ESoundOutputMethod.OpenAL => OpenALSoundOutput.GetDeviceNames(),
_ => Enumerable.Empty()
};
diff --git a/src/BizHawk.Client.EmuHawk/Program.cs b/src/BizHawk.Client.EmuHawk/Program.cs
index 2c13af0547..7c6697fcbb 100644
--- a/src/BizHawk.Client.EmuHawk/Program.cs
+++ b/src/BizHawk.Client.EmuHawk/Program.cs
@@ -181,17 +181,15 @@ namespace BizHawk.Client.EmuHawk
// possibly sharing config w/ Windows, assume the user wants the not-slow method (but don't change the config)
return TryInitIGL(EDispMethod.OpenGL);
}
- IGL_SlimDX9 glSlimDX;
try
{
- glSlimDX = new IGL_SlimDX9();
+ return CheckRenderer(IndirectX.CreateD3DGLImpl());
}
catch (Exception ex)
{
new ExceptionBox(new Exception("Initialization of Direct3d 9 Display Method failed; falling back to GDI+", ex)).ShowDialog();
return TryInitIGL(initialConfig.DispMethod = EDispMethod.GdiPlus);
}
- return CheckRenderer(glSlimDX);
case EDispMethod.OpenGL:
var glOpenTK = new IGL_TK(2, 0, false);
if (glOpenTK.Version < 200)
diff --git a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs
index 4c746e5e8b..483f540a49 100644
--- a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs
+++ b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs
@@ -51,8 +51,8 @@ namespace BizHawk.Client.EmuHawk
{
_outputDevice = config.SoundOutputMethod switch
{
- ESoundOutputMethod.DirectSound => new DirectSoundSoundOutput(this, mainWindowHandle, config.SoundDevice),
- ESoundOutputMethod.XAudio2 => new XAudio2SoundOutput(this, config.SoundDevice),
+ ESoundOutputMethod.DirectSound => IndirectX.CreateDSSoundOutput(this, mainWindowHandle, config.SoundDevice),
+ ESoundOutputMethod.XAudio2 => IndirectX.CreateXAudio2SoundOutput(this, config.SoundDevice),
ESoundOutputMethod.OpenAL => new OpenALSoundOutput(this, config.SoundDevice),
_ => new DummySoundOutput(this)
};