From 9ab62d8cd3cce2bb1990f91f06e7df2eed53f5d2 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 3 Jan 2020 14:36:13 -0600 Subject: [PATCH] some cleanup --- .../Sound/Output/DirectSoundSoundOutput.cs | 11 ++++------- BizHawk.Client.EmuHawk/Sound/Sound.cs | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs b/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs index 20d0959cad..28aa2953e8 100644 --- a/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs +++ b/BizHawk.Client.EmuHawk/Sound/Output/DirectSoundSoundOutput.cs @@ -12,8 +12,8 @@ namespace BizHawk.Client.EmuHawk { public class DirectSoundSoundOutput : ISoundOutput { + private readonly Sound _sound; private bool _disposed; - private Sound _sound; private DirectSound _device; private SecondarySoundBuffer _deviceBuffer; private int _actualWriteOffsetBytes = -1; @@ -21,11 +21,11 @@ namespace BizHawk.Client.EmuHawk private long _lastWriteTime; private int _lastWriteCursor; - public DirectSoundSoundOutput(Sound sound, IntPtr mainWindowHandle) + public DirectSoundSoundOutput(Sound sound, IntPtr mainWindowHandle, string soundDevice) { _sound = sound; - var deviceInfo = DirectSound.GetDevices().FirstOrDefault(d => d.Description == Global.Config.SoundDevice); + var deviceInfo = DirectSound.GetDevices().FirstOrDefault(d => d.Description == soundDevice); _device = deviceInfo != null ? new DirectSound(deviceInfo.DriverGuid) : new DirectSound(); _device.SetCooperativeLevel(mainWindowHandle, CooperativeLevel.Priority); } @@ -47,10 +47,7 @@ namespace BizHawk.Client.EmuHawk private int BufferSizeSamples { get; set; } - private int BufferSizeBytes - { - get { return BufferSizeSamples * Sound.BlockAlign; } - } + private int BufferSizeBytes => BufferSizeSamples * Sound.BlockAlign; public int MaxSamplesDeficit { get; private set; } diff --git a/BizHawk.Client.EmuHawk/Sound/Sound.cs b/BizHawk.Client.EmuHawk/Sound/Sound.cs index 5a27ba2329..39839ca0cb 100644 --- a/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -33,7 +33,7 @@ namespace BizHawk.Client.EmuHawk if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.OpenAL) _outputDevice = new OpenALSoundOutput(this); if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.DirectSound) - _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle); + _outputDevice = new DirectSoundSoundOutput(this, mainWindowHandle, Global.Config.SoundDevice); if (Global.Config.SoundOutputMethod == Config.ESoundOutputMethod.XAudio2) _outputDevice = new XAudio2SoundOutput(this); }