From 5dc7327c1f521407dc6fb35d687950c04f6fd7b2 Mon Sep 17 00:00:00 2001 From: pjgat09 Date: Sat, 23 Aug 2014 22:40:29 +0000 Subject: [PATCH] N64: Hopefully fix some crashes associated with restarting the core early in the emulation --- BizHawk.Emulation.Cores/Consoles/Nintendo/N64/N64Audio.cs | 7 ++++++- .../Consoles/Nintendo/N64/N64VideoProvider.cs | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) 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; } }