diff --git a/BizHawk.Client.EmuHawk/Sound/Sound.cs b/BizHawk.Client.EmuHawk/Sound/Sound.cs index 84362490e7..88a94e44c9 100644 --- a/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -15,6 +15,8 @@ namespace BizHawk.Client.EmuHawk public const int BlockAlign = BytesPerSample * ChannelCount; private bool _disposed; + private bool _unjamSoundThrottle; + private readonly ISoundOutput _outputDevice; private readonly SoundOutputProvider _outputProvider = new SoundOutputProvider(); // Buffer for Sync sources private readonly BufferedAsync _bufferedAsync = new BufferedAsync(); // Buffer for Async sources @@ -117,6 +119,7 @@ namespace BizHawk.Client.EmuHawk int silenceSamples = Math.Max(samplesNeeded - samplesPerFrame, 0); _outputDevice.WriteSamples(new short[silenceSamples * 2], silenceSamples); samplesNeeded -= silenceSamples; + _unjamSoundThrottle = isUnderrun; if (isUnderrun) { @@ -163,7 +166,14 @@ namespace BizHawk.Client.EmuHawk { Thread.Sleep((samplesProvided - samplesNeeded) / (SampleRate / 1000)); // Let the audio clock control sleep time samplesNeeded = _outputDevice.CalculateSamplesNeeded(); + if (_unjamSoundThrottle) + { + //may be garbage, but what can we do? + samplesProvided = samplesNeeded; + break; + } } + _unjamSoundThrottle = false; } else {