diff --git a/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs b/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs index 51898c9393..ea06515c68 100644 --- a/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs +++ b/src/BizHawk.Client.EmuHawk/Extensions/ControlExtensions.cs @@ -150,14 +150,14 @@ namespace BizHawk.Client.EmuHawk /// public static DialogResult ShowHawkDialog(this Form form, IWin32Window owner = null, Point position = default) { - GlobalWin.Sound.StopSound(); + Sound.Instance.StopSound(); if (position != default) { form.StartPosition = FormStartPosition.Manual; form.Location = position; } var result = (owner == null ? form.ShowDialog(new Form { TopMost = true }) : form.ShowDialog(owner)); - GlobalWin.Sound.StartSound(); + Sound.Instance.StartSound(); return result; } @@ -166,13 +166,13 @@ namespace BizHawk.Client.EmuHawk /// public static DialogResult ShowHawkDialog(this CommonDialog form, IWin32Window owner) { - GlobalWin.Sound.StopSound(); + Sound.Instance.StopSound(); DialogResult result; if(owner != null) result = form.ShowDialog(owner); else result = form.ShowDialog(); - GlobalWin.Sound.StartSound(); + Sound.Instance.StartSound(); return result; } } diff --git a/src/BizHawk.Client.EmuHawk/GlobalWin.cs b/src/BizHawk.Client.EmuHawk/GlobalWin.cs deleted file mode 100644 index 2f3ef7efe4..0000000000 --- a/src/BizHawk.Client.EmuHawk/GlobalWin.cs +++ /dev/null @@ -1,8 +0,0 @@ -// ReSharper disable StyleCop.SA1401 -namespace BizHawk.Client.EmuHawk -{ - public static class GlobalWin - { - public static Sound Sound; - } -} diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index cc0d6143ff..f4614fd122 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -416,7 +416,7 @@ namespace BizHawk.Client.EmuHawk InputManager.AutofireStickyXorAdapter.SetOnOffPatternFromConfig(Config.AutofireOn, Config.AutofireOff); try { - GlobalWin.Sound = new Sound(Handle, Config, Emulator.VsyncRate); + Sound = new Sound(Handle, Config, Emulator.VsyncRate); } catch { @@ -429,7 +429,7 @@ namespace BizHawk.Client.EmuHawk MessageBox.Show(message, "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Config.SoundOutputMethod = ESoundOutputMethod.Dummy; - GlobalWin.Sound = new Sound(Handle, Config, Emulator.VsyncRate); + Sound = new Sound(Handle, Config, Emulator.VsyncRate); } Sound.StartSound(); @@ -880,8 +880,8 @@ namespace BizHawk.Client.EmuHawk private Sound Sound { - get => GlobalWin.Sound; - set => GlobalWin.Sound = value; + get => Sound.Instance; + set => Sound.Instance = value; } public CheatCollection CheatList { get; } diff --git a/src/BizHawk.Client.EmuHawk/Program.cs b/src/BizHawk.Client.EmuHawk/Program.cs index 5844784ef5..bb4e18d888 100644 --- a/src/BizHawk.Client.EmuHawk/Program.cs +++ b/src/BizHawk.Client.EmuHawk/Program.cs @@ -252,8 +252,8 @@ namespace BizHawk.Client.EmuHawk } finally { - GlobalWin.Sound?.Dispose(); - GlobalWin.Sound = null; + Sound.Instance?.Dispose(); + Sound.Instance = null; workingGL.Dispose(); Input.Instance?.Adapter?.DeInitAll(); } diff --git a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs index a6dfea1bd1..0fc20f1dda 100644 --- a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -11,6 +11,8 @@ namespace BizHawk.Client.EmuHawk /// TODO rename to HostAudioManager public class Sound : IHostAudioManager, IDisposable { + public static Sound Instance; + public int SampleRate { get; } = 44100; public int BytesPerSample { get; } = 2;