Fix stuff or not

This commit is contained in:
nattthebear 2016-12-11 22:37:28 -05:00
parent 010fb01bf8
commit dbdac5e3f2
3 changed files with 71 additions and 4 deletions

View File

@ -35,6 +35,7 @@ using BizHawk.Client.EmuHawk.WinFormExtensions;
using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Client.EmuHawk.CoreExtensions;
using BizHawk.Client.ApiHawk;
using BizHawk.Emulation.Common.Base_Implementations;
namespace BizHawk.Client.EmuHawk
{
@ -1353,7 +1354,7 @@ namespace BizHawk.Client.EmuHawk
// Sound refator TODO: we can enforce async mode here with a property that gets/sets this but does an async check
private ISoundProvider _aviSoundInputAsync; // Note: This sound provider must be in async mode!
private MetaspuSoundProvider _dumpProxy; // an audio proxy used for dumping
private SimpleSyncSoundProvider _dumpProxy; // an audio proxy used for dumping
private bool _dumpaudiosync; // set true to for experimental AV dumping
private int _avwriterResizew;
private int _avwriterResizeh;
@ -1623,7 +1624,7 @@ namespace BizHawk.Client.EmuHawk
{
// we're video dumping, so async mode only and use the DumpProxy.
// note that the avi dumper has already rewired the emulator itself in this case.
GlobalWin.Sound.SetAsyncInputPin(_dumpProxy);
GlobalWin.Sound.SetSyncInputPin(_dumpProxy);
}
else if (Global.Config.SoundThrottle || !_currentSoundProvider.CanProvideAsync)
{
@ -3123,7 +3124,7 @@ namespace BizHawk.Client.EmuHawk
_aviSoundInputAsync = new MetaspuAsync(_currentSoundProvider, ESynchMethod.ESynchMethod_V);
}
}
_dumpProxy = new MetaspuSoundProvider(ESynchMethod.ESynchMethod_V);
_dumpProxy = new SimpleSyncSoundProvider();
RewireSound();
}
@ -3257,7 +3258,7 @@ namespace BizHawk.Client.EmuHawk
disposableOutput.Dispose();
}
_dumpProxy.Buffer.enqueue_samples(samp, nsamp);
_dumpProxy.PutSamples(samp, nsamp);
}
catch (Exception e)
{

View File

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BizHawk.Emulation.Common.Base_Implementations
{
/// <summary>
/// A simple sound provider that will operate in sync mode only, offering back whatever data was sent in PutSamples
/// </summary>
public class SimpleSyncSoundProvider : ISoundProvider
{
private short[] _buffer = new short[0];
private int _nsamp = 0;
public bool CanProvideAsync
{
get { return false; }
}
public void SetSyncMode(SyncSoundMode mode)
{
if (mode != SyncSoundMode.Sync)
throw new ArgumentException("Only supports Sync mode");
}
public SyncSoundMode SyncMode
{
get { return SyncSoundMode.Sync; }
}
/// <summary>
/// Add samples to be output. no queueing; must be drained every frame
/// </summary>
/// <param name="samples"></param>
/// <param name="nsamp"></param>
public void PutSamples(short[] samples, int nsamp)
{
if (_nsamp != 0)
Console.WriteLine("Warning: Samples disappeared from SimpleSyncSoundProvider");
if (_buffer.Length < nsamp * 2)
_buffer = new short[nsamp * 2];
Array.Copy(samples, _buffer, nsamp * 2);
_nsamp = nsamp;
}
public void GetSamplesSync(out short[] samples, out int nsamp)
{
samples = _buffer;
nsamp = _nsamp;
_nsamp = 0;
}
public void GetSamplesAsync(short[] samples)
{
throw new NotImplementedException();
}
public void DiscardSamples()
{
_nsamp = 0;
}
}
}

View File

@ -102,6 +102,7 @@
<Compile Include="Base Implementations\NullEmulator.cs" />
<Compile Include="Base Implementations\NullSound.cs" />
<Compile Include="Base Implementations\NullVideo.cs" />
<Compile Include="Base Implementations\SimpleSyncSoundProvider.cs" />
<Compile Include="Base Implementations\TraceBuffer.cs" />
<Compile Include="BinaryQuickSerializer.cs" />
<Compile Include="BizInvoke\BizInvoker.cs" />