a bit of cleanup in speex resampler and yabooze core

This commit is contained in:
goyuken 2013-12-11 04:01:33 +00:00
parent d12f4a10c6
commit 8b186f6fa4
3 changed files with 16 additions and 26 deletions

View File

@ -311,6 +311,9 @@ namespace BizHawk.Emulation.Common
/// <param name="input">source to take input from when output is requested. if null, no autofetching</param>
public SpeexResampler(int quality, uint rationum, uint ratioden, uint sratein, uint srateout, Action<short[], int> drainer = null, ISyncSoundProvider input = null)
{
if (drainer != null && input != null)
throw new ArgumentException("Can't autofetch without being an ISyncSoundProvider?");
LibSpeexDSP.RESAMPLER_ERR err = LibSpeexDSP.RESAMPLER_ERR.SUCCESS;
st = LibSpeexDSP.speex_resampler_init_frac(2, rationum, ratioden, sratein, srateout, quality, ref err);
@ -319,9 +322,6 @@ namespace BizHawk.Emulation.Common
CheckError(err);
if (drainer != null && input != null)
throw new ArgumentException("Can't autofetch without being an ISyncSoundProvider?");
this.drainer = drainer ?? InternalDrain;
this.input = input;

View File

@ -41,9 +41,9 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
public void Get(Stream s)
{
if (thr != null)
throw new Exception("Can only serve one thing at a time!");
throw new InvalidOperationException("Can only serve one thing at a time!");
if (e != null)
throw new Exception("Previous attempt failed!", e);
throw new InvalidOperationException("Previous attempt failed!", e);
if (!s.CanWrite)
throw new ArgumentException("Stream must be readable!");
@ -74,9 +74,9 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
public void Offer(Stream s)
{
if (thr != null)
throw new Exception("Can only serve one thing at a time!");
throw new InvalidOperationException("Can only serve one thing at a time!");
if (e != null)
throw new Exception("Previous attempt failed!", e);
throw new InvalidOperationException("Previous attempt failed!", e);
if (!s.CanRead)
throw new ArgumentException("Stream must be readable!");
@ -104,15 +104,15 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
}
}
public Exception GetResults()
public void Finish()
{
if (thr == null)
throw new Exception("No pending!");
throw new InvalidOperationException("No pending!");
thr.Join();
thr = null;
Exception ret = e;
e = null;
return ret;
if (ret != null)
throw ret;
}
}
}

View File

@ -79,9 +79,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
if (!LibYabause.libyabause_init(ref CDInt, BiosPipe, GL))
throw new Exception("libyabause_init() failed!");
var e = fp.GetResults();
if (e != null)
throw e;
fp.Finish();
LibYabause.libyabause_setvidbuff(VideoHandle.AddrOfPinnedObject());
LibYabause.libyabause_setsndbuff(SoundHandle.AddrOfPinnedObject());
@ -250,9 +248,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
var fp = new FilePiping();
fp.Get(ms);
bool success = LibYabause.libyabause_savesaveram(fp.GetPipeNameNative());
var e = fp.GetResults();
if (e != null)
throw e;
fp.Finish();
if (!success)
throw new Exception("libyabause_savesaveram() failed!");
var ret = ms.ToArray();
@ -273,9 +269,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
var fp = new FilePiping();
fp.Offer(data);
bool success = LibYabause.libyabause_loadsaveram(fp.GetPipeNameNative());
var e = fp.GetResults();
if (e != null)
throw e;
fp.Finish();
if (!success)
throw new Exception("libyabause_loadsaveram() failed!");
}
@ -321,9 +315,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
var fp = new FilePiping();
fp.Offer(data);
bool succeed = LibYabause.libyabause_loadstate(fp.GetPipeNameNative());
var e = fp.GetResults();
if (e != null)
throw e;
fp.Finish();
if (!succeed)
throw new Exception("libyabause_loadstate() failed");
}
@ -334,9 +326,7 @@ namespace BizHawk.Emulation.Cores.Sega.Saturn
var fp = new FilePiping();
fp.Get(ms);
bool succeed = LibYabause.libyabause_savestate(fp.GetPipeNameNative());
var e = fp.GetResults();
if (e != null)
throw e;
fp.Finish();
var ret = ms.ToArray();
ms.Close();
if (!succeed)