Move GlobalWin.DisableSecondaryThrottling to MainForm

This commit is contained in:
YoshiRulz 2020-11-26 21:36:23 +10:00
parent f0843689ed
commit 6dfb0a8af8
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 16 additions and 13 deletions

View File

@ -47,14 +47,17 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private readonly Func<bool> _getIsSecondaryThrottlingDisabled;
private readonly OSDManager _osdManager; private readonly OSDManager _osdManager;
private Config GlobalConfig => GlobalWin.Config; private Config GlobalConfig => GlobalWin.Config;
private IEmulator GlobalEmulator => GlobalWin.Emulator; private IEmulator GlobalEmulator => GlobalWin.Emulator;
public DisplayManager(OSDManager osdManager, IGL gl, PresentationPanel presentationPanel) public DisplayManager(OSDManager osdManager, IGL gl, PresentationPanel presentationPanel, Func<bool> getIsSecondaryThrottlingDisabled)
{ {
_getIsSecondaryThrottlingDisabled = getIsSecondaryThrottlingDisabled;
_osdManager = osdManager; _osdManager = osdManager;
GL = gl; GL = gl;
@ -934,7 +937,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 (GlobalWin.DisableSecondaryThrottling) if (_getIsSecondaryThrottlingDisabled())
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

@ -28,11 +28,6 @@ namespace BizHawk.Client.EmuHawk
public static int ExitCode; public static int ExitCode;
/// <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; }
public static Dictionary<string, object> UserBag { get; set; } = new Dictionary<string, object>(); public static Dictionary<string, object> UserBag { get; set; } = new Dictionary<string, object>();
public static Config Config { get; set; } public static Config Config { get; set; }

View File

@ -340,7 +340,7 @@ namespace BizHawk.Client.EmuHawk
{ {
GraphicsControl = { MainWindow = true } GraphicsControl = { MainWindow = true }
}; };
GlobalWin.DisplayManager = new DisplayManager(OSD, GlobalWin.GL, PresentationPanel); GlobalWin.DisplayManager = new DisplayManager(OSD, GlobalWin.GL, PresentationPanel, () => DisableSecondaryThrottling);
Controls.Add(PresentationPanel); Controls.Add(PresentationPanel);
Controls.SetChildIndex(PresentationPanel, 0); Controls.SetChildIndex(PresentationPanel, 0);
@ -793,6 +793,11 @@ namespace BizHawk.Client.EmuHawk
private bool IsTurboSeeking => PauseOnFrame.HasValue && Config.TurboSeek; private bool IsTurboSeeking => PauseOnFrame.HasValue && Config.TurboSeek;
public bool IsTurboing => InputManager.ClientControls["Turbo"] || IsTurboSeeking; public bool IsTurboing => InputManager.ClientControls["Turbo"] || IsTurboSeeking;
/// <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; }
public void AddOnScreenMessage(string message) => OSD.AddMessage(message); public void AddOnScreenMessage(string message) => OSD.AddMessage(message);
public void ClearHolds() public void ClearHolds()
@ -2063,7 +2068,7 @@ namespace BizHawk.Client.EmuHawk
speedPercent = Math.Max(speedPercent / Rewinder.RewindFrequency, 5); speedPercent = Math.Max(speedPercent / Rewinder.RewindFrequency, 5);
} }
GlobalWin.DisableSecondaryThrottling = _unthrottled || turbo || fastForward || rewind; 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());
@ -3019,7 +3024,7 @@ namespace BizHawk.Client.EmuHawk
UpdateToolsAfter(); UpdateToolsAfter();
} }
Sound.UpdateSound(atten); Sound.UpdateSound(atten, DisableSecondaryThrottling);
} }
private void UpdateFpsDisplay(long currentTimestamp, bool isRewinding, bool isFastForwarding) private void UpdateFpsDisplay(long currentTimestamp, bool isRewinding, bool isFastForwarding)

View File

@ -143,7 +143,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
public void UpdateSound(float atten) public void UpdateSound(float atten, bool isSecondaryThrottlingDisabled)
{ {
if (!GlobalWin.Config.SoundEnabled || !IsStarted || _bufferedProvider == null || _disposed) if (!GlobalWin.Config.SoundEnabled || !IsStarted || _bufferedProvider == null || _disposed)
{ {
@ -175,7 +175,7 @@ namespace BizHawk.Client.EmuHawk
_outputProvider.BaseSoundProvider.GetSamplesSync(out samples, out sampleCount); _outputProvider.BaseSoundProvider.GetSamplesSync(out samples, out sampleCount);
sampleOffset = 0; sampleOffset = 0;
if (GlobalWin.DisableSecondaryThrottling && sampleCount > samplesNeeded) if (isSecondaryThrottlingDisabled && sampleCount > samplesNeeded)
{ {
return; return;
} }
@ -203,7 +203,7 @@ namespace BizHawk.Client.EmuHawk
} }
else else
{ {
if (GlobalWin.DisableSecondaryThrottling) // This indicates rewind or fast-forward if (isSecondaryThrottlingDisabled) // This indicates rewind or fast-forward
{ {
_outputProvider.OnVolatility(); _outputProvider.OnVolatility();
} }