GB: cleanup and fix memory leaks for a few odd cases
This commit is contained in:
parent
2a0217e06c
commit
81996af187
|
@ -62,6 +62,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
if (GambatteState == IntPtr.Zero)
|
||||
throw new Exception("gambatte_create() returned null???");
|
||||
|
||||
try
|
||||
{
|
||||
LibGambatte.LoadFlags flags = 0;
|
||||
|
||||
if (game["ForceDMG"])
|
||||
|
@ -100,6 +102,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
TimeCallback = new LibGambatte.RTCCallback(GetCurrentTime);
|
||||
LibGambatte.gambatte_setrtccallback(GambatteState, TimeCallback);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Dispose();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly ControllerDefinition GbController = new ControllerDefinition
|
||||
{
|
||||
|
@ -739,9 +747,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
#endregion
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (GambatteState != IntPtr.Zero)
|
||||
{
|
||||
LibGambatte.gambatte_destroy(GambatteState);
|
||||
GambatteState = IntPtr.Zero;
|
||||
}
|
||||
DisposeSound();
|
||||
}
|
||||
|
||||
|
@ -826,9 +837,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
int latchaudio = 0;
|
||||
|
||||
//SpeexResampler resampler;
|
||||
//DCFilter dcfilter;
|
||||
|
||||
BlipBuffer blip;
|
||||
|
||||
void ProcessSound()
|
||||
|
@ -858,20 +866,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
void InitSound()
|
||||
{
|
||||
//resampler = new Sound.Utilities.SpeexResampler(2, 2097152, 44100, 2097152, 44100, null, this);
|
||||
//dcfilter = Sound.Utilities.DCFilter.AsISyncSoundProvider(resampler, 65536);
|
||||
// lowpass filtering on an actual GB was probably pretty aggressive?
|
||||
//dcfilter = Sound.Utilities.DCFilter.AsISyncSoundProvider(resampler, 2048);
|
||||
blip = new BlipBuffer(1024);
|
||||
blip.SetRates(2097152, 44100);
|
||||
}
|
||||
|
||||
void DisposeSound()
|
||||
{
|
||||
if (blip != null)
|
||||
{
|
||||
blip.Dispose();
|
||||
blip = null;
|
||||
//resampler.Dispose();
|
||||
//resampler = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void DiscardSamples()
|
||||
|
|
Loading…
Reference in New Issue