N64: Hopefully fix some crashes associated with restarting the core early in the emulation

This commit is contained in:
pjgat09 2014-08-23 22:40:29 +00:00
parent 1dd0499e89
commit 5dc7327c1f
2 changed files with 11 additions and 3 deletions

View File

@ -10,6 +10,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
/// mupen64 DLL Api
/// </summary>
private mupen64plusAudioApi api;
private mupen64plusApi coreAPI;
/// <summary>
/// Buffer for audio data
/// </summary>
@ -48,7 +51,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
Resampler = new SpeexResampler(6, SamplingRate, 44100,
SamplingRate, 44100);
core.VInterrupt += DoAudioFrame;
coreAPI = core;
coreAPI.VInterrupt += DoAudioFrame;
}
/// <summary>
@ -75,6 +79,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
public void Dispose()
{
coreAPI.VInterrupt -= DoAudioFrame;
if(Resampler != null)
Resampler.Dispose();
Resampler = null;

View File

@ -8,6 +8,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
{
private int[] frameBuffer;
private mupen64plusVideoApi api;
private mupen64plusApi coreAPI;
public bool IsVIFrame;
@ -27,8 +28,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
height > videosettings.Height ? height : videosettings.Height
);
core.BeforeRender += DoVideoFrame;
core.BeforeRender += () => { IsVIFrame = true; };
coreAPI = core;
coreAPI.BeforeRender += DoVideoFrame;
coreAPI.BeforeRender += () => { IsVIFrame = true; };
}
public int[] GetVideoBuffer()
@ -72,6 +74,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
public void Dispose()
{
coreAPI.BeforeRender -= DoVideoFrame;
api = null;
}
}