GBHawk: Attempt to fix audio crash

This commit is contained in:
alyosha-tas 2018-07-01 15:10:42 -04:00
parent 58240dfe05
commit 123df38731
2 changed files with 9 additions and 4 deletions

View File

@ -117,6 +117,7 @@ namespace BizHawk.Client.EmuHawk
_bufferPool.Release(_sourceVoice.State.BuffersQueued);
int byteCount = sampleCount * Sound.BlockAlign;
var buffer = _bufferPool.Obtain(byteCount);
if (byteCount > (samples.Length * 2)) { byteCount = samples.Length * 2; }
Buffer.BlockCopy(samples, 0, buffer.Bytes, 0, byteCount);
_sourceVoice.SubmitSourceBuffer(new AudioBuffer
{

View File

@ -12,8 +12,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
{
public GBHawk Core { get; set; }
private readonly BlipBuffer _blip_L = new BlipBuffer(15000);
private readonly BlipBuffer _blip_R = new BlipBuffer(15000);
private BlipBuffer _blip_L = new BlipBuffer(15000);
private BlipBuffer _blip_R = new BlipBuffer(15000);
public static int[] DUTY_CYCLES = new int[] {0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 0, 0, 1,
@ -1117,12 +1117,16 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBHawk
}
#endregion
public void DisposeSound()
{
_blip_L.Clear();
_blip_R.Clear();
_blip_L.Dispose();
_blip_R.Dispose();
_blip_L = null;
_blip_R = null;
}
#endregion
}
}