Move static GlobalWin.Sound to static Sound.Instance, mirroring Input

This commit is contained in:
YoshiRulz 2020-11-30 20:42:23 +10:00
parent c3a7ec047f
commit bf968acd57
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
5 changed files with 12 additions and 18 deletions

View File

@ -150,14 +150,14 @@ namespace BizHawk.Client.EmuHawk
/// </summary>
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
/// </summary>
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;
}
}

View File

@ -1,8 +0,0 @@
// ReSharper disable StyleCop.SA1401
namespace BizHawk.Client.EmuHawk
{
public static class GlobalWin
{
public static Sound Sound;
}
}

View File

@ -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; }

View File

@ -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();
}

View File

@ -11,6 +11,8 @@ namespace BizHawk.Client.EmuHawk
/// <remarks>TODO rename to <c>HostAudioManager</c></remarks>
public class Sound : IHostAudioManager, IDisposable
{
public static Sound Instance;
public int SampleRate { get; } = 44100;
public int BytesPerSample { get; } = 2;