From 47fa5bcb7c8e78e3341be80dc0ee2b89cc721814 Mon Sep 17 00:00:00 2001 From: nattthebear Date: Sun, 11 Dec 2016 14:16:25 -0500 Subject: [PATCH] Minor cleanup --- BizHawk.Client.EmuHawk/Sound/Sound.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Sound/Sound.cs b/BizHawk.Client.EmuHawk/Sound/Sound.cs index 8d2cc6d5f0..043c37f053 100644 --- a/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -83,8 +83,14 @@ namespace BizHawk.Client.EmuHawk } // Sound refactor TODO: combine these methods, and check the SyncMode for behavior + /// + /// attach a new input pin, of the `sync` variety + /// public void SetSyncInputPin(ISoundProvider source) { + if (source.SyncMode != SyncSoundMode.Sync) + throw new InvalidOperationException("SetSyncInputPin() must be called with a sync input"); + _semiSync.DiscardSamples(); _semiSync.ClearSoundProvider(); _soundProvider = source; @@ -94,8 +100,14 @@ namespace BizHawk.Client.EmuHawk } } + /// + /// attach a new input pin, of the `async` variety + /// public void SetAsyncInputPin(ISoundProvider source) { + if (source.SyncMode != SyncSoundMode.Async) + throw new InvalidOperationException("SetAsyncInputPin() must be called with a async input"); + if (_outputProvider != null) { _outputProvider.DiscardSamples(); @@ -160,7 +172,7 @@ namespace BizHawk.Client.EmuHawk int samplesNeeded = _soundOutput.CalculateSamplesNeeded(); int samplesProvided; - if (atten==0) + if (atten == 0) { samples = new short[samplesNeeded * ChannelCount]; samplesProvided = samplesNeeded; @@ -168,7 +180,7 @@ namespace BizHawk.Client.EmuHawk if (_soundProvider != null) _soundProvider.DiscardSamples(); if (_outputProvider != null) _outputProvider.DiscardSamples(); } - else if ( _soundProvider.SyncMode == SyncSoundMode.Sync) + else if (_soundProvider.SyncMode == SyncSoundMode.Sync) { if (Global.Config.SoundThrottle) {