Move SoundMaxBufferDeficitMs and DisableSecondaryThrottling from Global to GlobalWin or Sound class, since only EmuHawk code accesses these

This commit is contained in:
adelikat 2020-05-25 15:40:23 -05:00
parent aec01b794a
commit 2ce79fc356
6 changed files with 17 additions and 17 deletions

View File

@ -14,16 +14,6 @@ namespace BizHawk.Client.Common
public static IMovieSession MovieSession { get; set; } public static IMovieSession MovieSession { get; set; }
/// <summary>
/// Used to disable secondary throttling (e.g. vsync, audio) for unthrottled modes or when the primary (clock) throttle is taking over (e.g. during fast forward/rewind).
/// </summary>
public static bool DisableSecondaryThrottling { get; set; }
/// <summary>
/// The maximum number of milliseconds the sound output buffer can go below full before causing a noticeable sound interruption.
/// </summary>
public static int SoundMaxBufferDeficitMs { get; set; }
public static InputManager InputManager { get; } = new InputManager(); public static InputManager InputManager { get; } = new InputManager();
public static Dictionary<string, object> UserBag { get; set; } = new Dictionary<string, object>(); public static Dictionary<string, object> UserBag { get; set; } = new Dictionary<string, object>();

View File

@ -914,7 +914,7 @@ namespace BizHawk.Client.EmuHawk
//this makes sense... but we don't have the infrastructure to support it now (we'd have to enable triple buffering or something like that) //this makes sense... but we don't have the infrastructure to support it now (we'd have to enable triple buffering or something like that)
//so what we're gonna do is disable vsync no matter what if throttling is off, and maybe nobody will notice. //so what we're gonna do is disable vsync no matter what if throttling is off, and maybe nobody will notice.
//update 26-mar-2016: this upsets me. When fast-forwarding and skipping frames, vsync should still work. But I'm not changing it yet //update 26-mar-2016: this upsets me. When fast-forwarding and skipping frames, vsync should still work. But I'm not changing it yet
if (Global.DisableSecondaryThrottling) if (GlobalWin.DisableSecondaryThrottling)
vsync = false; vsync = false;
//for now, it's assumed that the presentation panel is the main window, but that may not always be true //for now, it's assumed that the presentation panel is the main window, but that may not always be true

View File

@ -27,5 +27,10 @@ namespace BizHawk.Client.EmuHawk
public static Communication.HttpCommunication httpCommunication = null; public static Communication.HttpCommunication httpCommunication = null;
public static Communication.SocketServer socketServer = null; public static Communication.SocketServer socketServer = null;
public static Communication.MemoryMappedFiles memoryMappedFiles = null; public static Communication.MemoryMappedFiles memoryMappedFiles = null;
/// <summary>
/// Used to disable secondary throttling (e.g. vsync, audio) for unthrottled modes or when the primary (clock) throttle is taking over (e.g. during fast forward/rewind).
/// </summary>
public static bool DisableSecondaryThrottling { get; set; }
} }
} }

View File

@ -2030,7 +2030,7 @@ namespace BizHawk.Client.EmuHawk
speedPercent = Math.Max(speedPercent * Config.Rewind.SpeedMultiplier / Rewinder.RewindFrequency, 5); speedPercent = Math.Max(speedPercent * Config.Rewind.SpeedMultiplier / Rewinder.RewindFrequency, 5);
} }
Global.DisableSecondaryThrottling = _unthrottled || turbo || fastForward || rewind; GlobalWin.DisableSecondaryThrottling = _unthrottled || turbo || fastForward || rewind;
// realtime throttle is never going to be so exact that using a double here is wrong // realtime throttle is never going to be so exact that using a double here is wrong
_throttle.SetCoreFps(Emulator.VsyncRate()); _throttle.SetCoreFps(Emulator.VsyncRate());

View File

@ -41,6 +41,11 @@ namespace BizHawk.Client.EmuHawk
_outputDevice = new DummySoundOutput(this); _outputDevice = new DummySoundOutput(this);
} }
/// <summary>
/// The maximum number of milliseconds the sound output buffer can go below full before causing a noticeable sound interruption.
/// </summary>
public int SoundMaxBufferDeficitMs { get; set; }
public void Dispose() public void Dispose()
{ {
if (_disposed) return; if (_disposed) return;
@ -64,7 +69,7 @@ namespace BizHawk.Client.EmuHawk
_outputProvider.MaxSamplesDeficit = _outputDevice.MaxSamplesDeficit; _outputProvider.MaxSamplesDeficit = _outputDevice.MaxSamplesDeficit;
Global.SoundMaxBufferDeficitMs = (int)Math.Ceiling(SamplesToMilliseconds(_outputDevice.MaxSamplesDeficit)); SoundMaxBufferDeficitMs = (int)Math.Ceiling(SamplesToMilliseconds(_outputDevice.MaxSamplesDeficit));
IsStarted = true; IsStarted = true;
} }
@ -77,7 +82,7 @@ namespace BizHawk.Client.EmuHawk
_bufferedProvider?.DiscardSamples(); _bufferedProvider?.DiscardSamples();
Global.SoundMaxBufferDeficitMs = 0; SoundMaxBufferDeficitMs = 0;
IsStarted = false; IsStarted = false;
} }
@ -161,7 +166,7 @@ namespace BizHawk.Client.EmuHawk
_outputProvider.BaseSoundProvider.GetSamplesSync(out samples, out sampleCount); _outputProvider.BaseSoundProvider.GetSamplesSync(out samples, out sampleCount);
sampleOffset = 0; sampleOffset = 0;
if (Global.DisableSecondaryThrottling && sampleCount > samplesNeeded) if (GlobalWin.DisableSecondaryThrottling && sampleCount > samplesNeeded)
{ {
return; return;
} }
@ -189,7 +194,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (Global.DisableSecondaryThrottling) // This indicates rewind or fast-forward if (GlobalWin.DisableSecondaryThrottling) // This indicates rewind or fast-forward
{ {
_outputProvider.OnVolatility(); _outputProvider.OnVolatility();
} }

View File

@ -322,7 +322,7 @@ namespace BizHawk.Client.EmuHawk
if (elapsedTime >= timePerFrame) if (elapsedTime >= timePerFrame)
{ {
int maxMissedFrames = (int)Math.Ceiling((Global.SoundMaxBufferDeficitMs / 1000.0) / ((double)timePerFrame / afsfreq)); int maxMissedFrames = (int)Math.Ceiling((GlobalWin.Sound.SoundMaxBufferDeficitMs / 1000.0) / ((double)timePerFrame / afsfreq));
if (maxMissedFrames < 3) if (maxMissedFrames < 3)
maxMissedFrames = 3; maxMissedFrames = 3;