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)
|
if (GambatteState == IntPtr.Zero)
|
||||||
throw new Exception("gambatte_create() returned null???");
|
throw new Exception("gambatte_create() returned null???");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
LibGambatte.LoadFlags flags = 0;
|
LibGambatte.LoadFlags flags = 0;
|
||||||
|
|
||||||
if (game["ForceDMG"])
|
if (game["ForceDMG"])
|
||||||
|
@ -100,6 +102,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
TimeCallback = new LibGambatte.RTCCallback(GetCurrentTime);
|
TimeCallback = new LibGambatte.RTCCallback(GetCurrentTime);
|
||||||
LibGambatte.gambatte_setrtccallback(GambatteState, TimeCallback);
|
LibGambatte.gambatte_setrtccallback(GambatteState, TimeCallback);
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly ControllerDefinition GbController = new ControllerDefinition
|
public static readonly ControllerDefinition GbController = new ControllerDefinition
|
||||||
{
|
{
|
||||||
|
@ -739,9 +747,12 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (GambatteState != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
LibGambatte.gambatte_destroy(GambatteState);
|
LibGambatte.gambatte_destroy(GambatteState);
|
||||||
GambatteState = IntPtr.Zero;
|
GambatteState = IntPtr.Zero;
|
||||||
|
}
|
||||||
DisposeSound();
|
DisposeSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,9 +837,6 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
|
|
||||||
int latchaudio = 0;
|
int latchaudio = 0;
|
||||||
|
|
||||||
//SpeexResampler resampler;
|
|
||||||
//DCFilter dcfilter;
|
|
||||||
|
|
||||||
BlipBuffer blip;
|
BlipBuffer blip;
|
||||||
|
|
||||||
void ProcessSound()
|
void ProcessSound()
|
||||||
|
@ -858,20 +866,17 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
|
|
||||||
void InitSound()
|
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 = new BlipBuffer(1024);
|
||||||
blip.SetRates(2097152, 44100);
|
blip.SetRates(2097152, 44100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisposeSound()
|
void DisposeSound()
|
||||||
|
{
|
||||||
|
if (blip != null)
|
||||||
{
|
{
|
||||||
blip.Dispose();
|
blip.Dispose();
|
||||||
blip = null;
|
blip = null;
|
||||||
//resampler.Dispose();
|
}
|
||||||
//resampler = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DiscardSamples()
|
public void DiscardSamples()
|
||||||
|
|
Loading…
Reference in New Issue