diff --git a/BizHawk.Emulation/Consoles/Calculator/TI83.cs b/BizHawk.Emulation/Consoles/Calculator/TI83.cs index f158306079..56e78d8df1 100644 --- a/BizHawk.Emulation/Consoles/Calculator/TI83.cs +++ b/BizHawk.Emulation/Consoles/Calculator/TI83.cs @@ -366,8 +366,7 @@ namespace BizHawk.Emulation.Consoles.Calculator } public IVideoProvider VideoProvider { get { return new MyVideoProvider(this); } } - - public ISoundProvider SoundProvider { get { return new NullEmulator(); } } + public ISoundProvider SoundProvider { get { return NullSound.SilenceProvider; } } public static readonly ControllerDefinition TI83Controller = new ControllerDefinition @@ -575,5 +574,7 @@ namespace BizHawk.Emulation.Consoles.Calculator { return null; } + + public void Dispose() { } } } \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Gameboy/Gameboy.cs b/BizHawk.Emulation/Consoles/Gameboy/Gameboy.cs index 85bf7dc035..4670a61551 100644 --- a/BizHawk.Emulation/Consoles/Gameboy/Gameboy.cs +++ b/BizHawk.Emulation/Consoles/Gameboy/Gameboy.cs @@ -855,5 +855,7 @@ namespace BizHawk.Emulation.Consoles.Gameboy { return null; } + + public void Dispose() {} } } \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs index 000120183b..b1d3170705 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs @@ -460,7 +460,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo bw.Flush(); return ms.ToArray(); } - } + + public void Dispose() {} + } } //todo diff --git a/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs b/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs index d88e91f634..e9bf9c2246 100644 --- a/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs +++ b/BizHawk.Emulation/Consoles/PC Engine/PCEngine.cs @@ -308,5 +308,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx return null; } } + + public void Dispose() {} } } diff --git a/BizHawk.Emulation/Consoles/Sega/Genesis/Genesis.cs b/BizHawk.Emulation/Consoles/Sega/Genesis/Genesis.cs index e4f6fe7684..8ca3602158 100644 --- a/BizHawk.Emulation/Consoles/Sega/Genesis/Genesis.cs +++ b/BizHawk.Emulation/Consoles/Sega/Genesis/Genesis.cs @@ -195,5 +195,7 @@ namespace BizHawk.Emulation.Consoles.Sega { return null; } + + public void Dispose() {} } } \ No newline at end of file diff --git a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs index cceeb0d371..8b09211d19 100644 --- a/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs +++ b/BizHawk.Emulation/Consoles/Sega/SMS/SMS.cs @@ -379,5 +379,7 @@ namespace BizHawk.Emulation.Consoles.Sega return DisplayType == DisplayType.NTSC ? 60d : 50d; return null; } + + public void Dispose() {} } } \ No newline at end of file diff --git a/BizHawk.Emulation/Interfaces/Base Implementations/NullEmulator.cs b/BizHawk.Emulation/Interfaces/Base Implementations/NullEmulator.cs index fc9a9acbd0..d9542e28b3 100644 --- a/BizHawk.Emulation/Interfaces/Base Implementations/NullEmulator.cs +++ b/BizHawk.Emulation/Interfaces/Base Implementations/NullEmulator.cs @@ -29,9 +29,6 @@ namespace BizHawk public ControllerDefinition ControllerDefinition { get { return NullController; } } public IController Controller { get; set; } - //public string GetControllersAsMnemonic() { return "|.|.|"; } - //public void SetControllersAsMnemonic(string mnemonic) { return; } - public int Frame { get; set; } public int LagCount { get { return 0; } set { return; } } public bool IsLagFrame { get { return false; } } @@ -53,10 +50,18 @@ namespace BizHawk private IList memoryDomains; public IList MemoryDomains { get { return memoryDomains; } } public MemoryDomain MainMemory { get { return memoryDomains[0]; } } - + public void Dispose() { } public object Query(EmulatorQuery query) { return null; } } + + public class NullSound : ISoundProvider + { + public static readonly NullSound SilenceProvider = new NullSound(); + + public void GetSamples(short[] samples) { } + public void DiscardSamples() { } + } } diff --git a/BizHawk.Emulation/Interfaces/IEmulator.cs b/BizHawk.Emulation/Interfaces/IEmulator.cs index 49f49d0cff..556972289c 100644 --- a/BizHawk.Emulation/Interfaces/IEmulator.cs +++ b/BizHawk.Emulation/Interfaces/IEmulator.cs @@ -4,7 +4,7 @@ using System.IO; namespace BizHawk { - public interface IEmulator + public interface IEmulator : IDisposable { IVideoProvider VideoProvider { get; } ISoundProvider SoundProvider { get; } diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 0b135073cc..ccf43a5500 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Threading; using System.Drawing; using System.Drawing.Imaging; @@ -720,6 +719,7 @@ namespace BizHawk.MultiClient } CloseGame(); + Global.Emulator.Dispose(); Global.Emulator = nextEmulator; Global.Game = game; SyncControls(); @@ -795,6 +795,7 @@ namespace BizHawk.MultiClient writer.Write(Global.Emulator.SaveRam, 0, len); writer.Close(); } + Global.Emulator.Dispose(); Global.Emulator = new NullEmulator(); Global.ActiveController = Global.NullControls; UserMovie.StopMovie(); @@ -1151,11 +1152,10 @@ namespace BizHawk.MultiClient InputLog.GetMnemonic(); } - if(genSound) + if (genSound) Global.Sound.UpdateSound(Global.Emulator.SoundProvider); else - Global.Sound.UpdateSound(new NullEmulator()); //generates silence - + Global.Sound.UpdateSound(NullSound.SilenceProvider); } private void MakeScreenshot(string path)