Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/BizHawk.Emulation.Common/Interfaces/Services/ISoundProvider.cs
2 views
namespace BizHawk.Emulation.Common
{
	public enum SyncSoundMode { Sync, Async };

	/// <summary>
	/// This service provides the ability to output sound from the client,
	/// If available the client will provide sound ouput
	/// If unavailable the client will fallback to a default sound implementation
	/// that generates empty samples (silence)
	/// </summary>
	public interface ISoundProvider : IEmulatorService
	{
		/// <summary>
		/// Returns true if a core can provide Async sound
		/// </summary>
		bool CanProvideAsync { get; }

		/// <summary>
		/// Sets sync or async sound mode,
		/// Sync should be the default mode if not set
		/// All implementations must provide sync
		/// If a core can not provide async sound and the mode is set to sync,
		/// an NotSupportedException should be thrown
		/// </summary>
		void SetSyncMode(SyncSoundMode mode);

		/// <summary>
		/// Reports which mode the sound provider is currently in
		/// </summary>
		SyncSoundMode SyncMode { get; }

		/// <summary>
		/// Provides samples in syncmode
		/// If the core is not in sync mode, this should throw an InvalidOperationException
		/// </summary>
		void GetSamplesSync(out short[] samples, out int nsamp);

		/// <summary>
		/// Provides samples in async mode
		/// If the core is not in async mode, this shoudl throw an InvalidOperationException
		/// </summary>
		/// <param name="samples"></param>
		void GetSamplesAsync(short[] samples);

		/// <summary>
		/// Discards stuff, is there anything more to say here?
		/// </summary>
		void DiscardSamples();
	}
}