BizHawk/BizHawk.Client.EmuHawk/Sound/Utilities/SyncToAsyncProvider.cs

50 lines
1.0 KiB
C#

using System;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public class SyncToAsyncProvider : ISoundProvider
{
private readonly SoundOutputProvider _outputProvider = new SoundOutputProvider(standaloneMode: true);
public SyncToAsyncProvider(ISoundProvider baseProvider)
{
_outputProvider.BaseSoundProvider = baseProvider;
}
public void DiscardSamples()
{
_outputProvider.DiscardSamples();
}
public bool CanProvideAsync
{
get { return true; }
}
public SyncSoundMode SyncMode
{
get { return SyncSoundMode.Async; }
}
public void SetSyncMode(SyncSoundMode mode)
{
if (mode != SyncSoundMode.Async)
{
throw new NotSupportedException("Sync mode is not supported.");
}
}
public void GetSamplesSync(out short[] samples, out int nsamp)
{
throw new InvalidOperationException("Sync mode is not supported.");
}
public void GetSamplesAsync(short[] samples)
{
_outputProvider.GetSamples(samples);
}
}
}