Fix AooRE due to malformed response from wbox core (seen in melonDS)
This commit is contained in:
parent
d52e67b9e9
commit
ae74e37d2d
|
@ -13,6 +13,8 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
public abstract class WaterboxCore : IEmulator, IVideoProvider, ISoundProvider, IStatable,
|
||||
IInputPollable, ISaveRam
|
||||
{
|
||||
private const int AUDIO_CHANNEL_COUNT = 2;
|
||||
|
||||
private LibWaterboxCore _core;
|
||||
protected WaterboxHost _exe;
|
||||
protected ICallingConventionAdapter _adapter;
|
||||
|
@ -37,7 +39,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
BufferWidth = c.DefaultWidth;
|
||||
BufferHeight = c.DefaultHeight;
|
||||
_videoBuffer = new int[c.MaxWidth * c.MaxHeight];
|
||||
_soundBuffer = new short[c.MaxSamples * 2];
|
||||
_soundBuffer = new short[AUDIO_CHANNEL_COUNT * c.MaxSamples]; //TODO rename prop to MaxSamplesPerChannel
|
||||
VsyncNumerator = c.DefaultFpsNumerator;
|
||||
VsyncDenominator = c.DefaultFpsDenominator;
|
||||
_serviceProvider = new BasicServiceProvider(this);
|
||||
|
@ -206,6 +208,7 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
var frame = FrameAdvancePrep(controller, render, rendersound);
|
||||
frame.VideoBuffer = (IntPtr)vp;
|
||||
frame.SoundBuffer = (IntPtr)sp;
|
||||
//TODO it seems no-one thought to let the core know the LENGTH of either buffer; is it actually writing past the end? --yoshi
|
||||
|
||||
_core.FrameAdvance(frame);
|
||||
|
||||
|
@ -336,10 +339,20 @@ namespace BizHawk.Emulation.Cores.Waterbox
|
|||
}
|
||||
}
|
||||
|
||||
private string/*?*/ _finalCoreName = null;
|
||||
|
||||
private string FinalCoreName => _finalCoreName ??= this.Attributes().CoreName;
|
||||
|
||||
public void GetSamplesSync(out short[] samples, out int nsamp)
|
||||
{
|
||||
samples = _soundBuffer;
|
||||
nsamp = _numSamples;
|
||||
var maxPerChannel = samples.Length / AUDIO_CHANNEL_COUNT;
|
||||
if (maxPerChannel < nsamp)
|
||||
{
|
||||
Util.DebugWriteLine($"FrameAdvance in Waterbox core {FinalCoreName} claimed to have written {AUDIO_CHANNEL_COUNT}x{nsamp} audio samples but buffer is only {AUDIO_CHANNEL_COUNT}x{maxPerChannel} long!");
|
||||
nsamp = maxPerChannel;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetSamplesAsync(short[] samples)
|
||||
|
|
Loading…
Reference in New Issue