diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs
index 3ab3f22a61..8bb58fe039 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs
@@ -10,6 +10,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
/// mupen64 DLL Api
///
private mupen64plusAudioApi api;
+
+ private mupen64plusApi coreAPI;
+
///
/// Buffer for audio data
///
@@ -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;
}
///
@@ -75,6 +79,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64
public void Dispose()
{
+ coreAPI.VInterrupt -= DoAudioFrame;
if(Resampler != null)
Resampler.Dispose();
Resampler = null;
diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs
index 26748925fe..3d0ecc4499 100644
--- a/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs
+++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64VideoProvider.cs
@@ -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;
}
}