fix hangs when sound throttle is enabled and cores go a long time without giving samples. i mean,
This commit is contained in:
parent
a374f9f4b8
commit
2b53f9b954
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue