From 347ed0d4041e8545f924e7a020c161816c45c405 Mon Sep 17 00:00:00 2001 From: YoshiRulz <OSSYoshiRulz@gmail.com> Date: Sun, 7 Jun 2020 18:06:35 +1000 Subject: [PATCH] Cleanup Sound ctor --- src/BizHawk.Client.EmuHawk/Sound/Sound.cs | 32 +++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs index 2def9ae7f2..886df24706 100644 --- a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -22,25 +22,23 @@ namespace BizHawk.Client.EmuHawk public Sound(IntPtr mainWindowHandle) { - if (GlobalWin.Config.SoundOutputMethod != ESoundOutputMethod.Dummy) + if (OSTailoredCode.IsUnixHost) { - if (OSTailoredCode.IsUnixHost) - { - // at the moment unix/mono can only support OpenAL (so ignore whatever is set in the config) - _outputDevice = new OpenALSoundOutput(this); - } - else - { - if (GlobalWin.Config.SoundOutputMethod == ESoundOutputMethod.OpenAL) - _outputDevice = new OpenALSoundOutput(this); - if (GlobalWin.Config.SoundOutputMethod == ESoundOutputMethod.DirectSound) - _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle, GlobalWin.Config.SoundDevice); - if (GlobalWin.Config.SoundOutputMethod == ESoundOutputMethod.XAudio2) - _outputDevice = new XAudio2SoundOutput(this); - } + // if DirectSound or XAudio is chosen, use OpenAL, otherwise comply with the user's choice + _outputDevice = GlobalWin.Config.SoundOutputMethod == ESoundOutputMethod.Dummy + ? (ISoundOutput) new DummySoundOutput(this) + : new OpenALSoundOutput(this); + } + else + { + _outputDevice = GlobalWin.Config.SoundOutputMethod switch + { + ESoundOutputMethod.DirectSound => new DirectSoundSoundOutput(this, mainWindowHandle, GlobalWin.Config.SoundDevice), + ESoundOutputMethod.XAudio2 => new XAudio2SoundOutput(this), + ESoundOutputMethod.OpenAL => new OpenALSoundOutput(this), + _ => new DummySoundOutput(this) + }; } - if (_outputDevice == null) - _outputDevice = new DummySoundOutput(this); } /// <summary>