IEmulator now implements IDisposable; client now disposes cores

This commit is contained in:
beirich 2011-06-02 02:59:18 +00:00
parent 013487bf77
commit 9283a9f37d
9 changed files with 28 additions and 12 deletions

View File

@ -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() { }
}
}

View File

@ -855,5 +855,7 @@ namespace BizHawk.Emulation.Consoles.Gameboy
{
return null;
}
public void Dispose() {}
}
}

View File

@ -460,7 +460,9 @@ namespace BizHawk.Emulation.Consoles.Nintendo
bw.Flush();
return ms.ToArray();
}
}
public void Dispose() {}
}
}
//todo

View File

@ -308,5 +308,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
return null;
}
}
public void Dispose() {}
}
}

View File

@ -195,5 +195,7 @@ namespace BizHawk.Emulation.Consoles.Sega
{
return null;
}
public void Dispose() {}
}
}

View File

@ -379,5 +379,7 @@ namespace BizHawk.Emulation.Consoles.Sega
return DisplayType == DisplayType.NTSC ? 60d : 50d;
return null;
}
public void Dispose() {}
}
}

View File

@ -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<MemoryDomain> memoryDomains;
public IList<MemoryDomain> 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() { }
}
}

View File

@ -4,7 +4,7 @@ using System.IO;
namespace BizHawk
{
public interface IEmulator
public interface IEmulator : IDisposable
{
IVideoProvider VideoProvider { get; }
ISoundProvider SoundProvider { get; }

View File

@ -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)