fix sound buffering bugs and restore hookups for mute frameadvance option

This commit is contained in:
zeromus 2011-02-21 19:06:54 +00:00
parent ae11756cf0
commit 0f9c38f50b
2 changed files with 23 additions and 6 deletions

View File

@ -181,13 +181,11 @@ namespace BizHawk.MultiClient
private void PauseEmulator() private void PauseEmulator()
{ {
EmulatorPaused = true; EmulatorPaused = true;
Global.Sound.StopSound();
} }
private void UnpauseEmulator() private void UnpauseEmulator()
{ {
EmulatorPaused = false; EmulatorPaused = false;
Global.Sound.StartSound();
} }
private void LoadRomFromRecent(string rom) private void LoadRomFromRecent(string rom)
@ -620,14 +618,23 @@ namespace BizHawk.MultiClient
runFrame = true; runFrame = true;
} }
bool genSound = false;
if (runFrame) if (runFrame)
{ {
CaptureRewindState(); CaptureRewindState();
if (!runloop_frameadvance) genSound = true;
else if (!Global.Config.MuteFrameAdvance)
genSound = true;
Global.Emulator.FrameAdvance(!throttle.skipnextframe); Global.Emulator.FrameAdvance(!throttle.skipnextframe);
Global.Sound.UpdateSound(Global.Emulator.SoundProvider);
RamWatch1.UpdateValues(); RamWatch1.UpdateValues();
RamSearch1.UpdateValues(); RamSearch1.UpdateValues();
} }
if(genSound)
Global.Sound.UpdateSound(Global.Emulator.SoundProvider);
else
Global.Sound.UpdateSound(new NullEmulator()); //generates silence
} }
private void TakeScreenshot() private void TakeScreenshot()

View File

@ -46,7 +46,7 @@ namespace BizHawk.MultiClient
if (disposed) throw new ObjectDisposedException("Sound"); if (disposed) throw new ObjectDisposedException("Sound");
if (SoundEnabled == false) return; if (SoundEnabled == false) return;
if ((DSoundBuffer.Status & BufferStatus.Playing) != 0) if(IsPlaying)
return; return;
DSoundBuffer.Write(SoundBuffer, 0, LockFlags.EntireBuffer); DSoundBuffer.Write(SoundBuffer, 0, LockFlags.EntireBuffer);
@ -55,9 +55,19 @@ namespace BizHawk.MultiClient
DSoundBuffer.Play(0, PlayFlags.Looping); 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; return;
for (int i = 0; i < SoundBuffer.Length; i++) for (int i = 0; i < SoundBuffer.Length; i++)
SoundBuffer[i] = 0; SoundBuffer[i] = 0;