From 0f9c38f50ba098e689efac8b8bc658a47690aa95 Mon Sep 17 00:00:00 2001 From: zeromus Date: Mon, 21 Feb 2011 19:06:54 +0000 Subject: [PATCH] fix sound buffering bugs and restore hookups for mute frameadvance option --- BizHawk.MultiClient/MainForm.cs | 13 ++++++++++--- BizHawk.MultiClient/Sound.cs | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index 705db9f3a7..825c027dbf 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -181,13 +181,11 @@ namespace BizHawk.MultiClient private void PauseEmulator() { EmulatorPaused = true; - Global.Sound.StopSound(); } private void UnpauseEmulator() { EmulatorPaused = false; - Global.Sound.StartSound(); } private void LoadRomFromRecent(string rom) @@ -620,14 +618,23 @@ namespace BizHawk.MultiClient runFrame = true; } + bool genSound = false; if (runFrame) { CaptureRewindState(); + if (!runloop_frameadvance) genSound = true; + else if (!Global.Config.MuteFrameAdvance) + genSound = true; Global.Emulator.FrameAdvance(!throttle.skipnextframe); - Global.Sound.UpdateSound(Global.Emulator.SoundProvider); RamWatch1.UpdateValues(); RamSearch1.UpdateValues(); } + + if(genSound) + Global.Sound.UpdateSound(Global.Emulator.SoundProvider); + else + Global.Sound.UpdateSound(new NullEmulator()); //generates silence + } private void TakeScreenshot() diff --git a/BizHawk.MultiClient/Sound.cs b/BizHawk.MultiClient/Sound.cs index 943ef9f39a..7fb20efc85 100644 --- a/BizHawk.MultiClient/Sound.cs +++ b/BizHawk.MultiClient/Sound.cs @@ -46,7 +46,7 @@ namespace BizHawk.MultiClient if (disposed) throw new ObjectDisposedException("Sound"); if (SoundEnabled == false) return; - if ((DSoundBuffer.Status & BufferStatus.Playing) != 0) + if(IsPlaying) return; DSoundBuffer.Write(SoundBuffer, 0, LockFlags.EntireBuffer); @@ -55,9 +55,19 @@ namespace BizHawk.MultiClient DSoundBuffer.Play(0, PlayFlags.Looping); } - public void StopSound() + bool IsPlaying + { + get + { + if (DSoundBuffer == null) return false; + if ((DSoundBuffer.Status & BufferStatus.Playing) != 0) return true; + return false; + } + } + + public void StopSound() { - if ((DSoundBuffer.Status & BufferStatus.Playing) ==0) + if(!IsPlaying) return; for (int i = 0; i < SoundBuffer.Length; i++) SoundBuffer[i] = 0;