Move `SoundConfig.ApplyNewSoundDevice` logic to callsite
This commit is contained in:
parent
6f0953aaa3
commit
707ec53bd5
|
@ -947,21 +947,22 @@ namespace BizHawk.Client.EmuHawk
|
|||
ESoundOutputMethod.OpenAL => OpenALSoundOutput.GetDeviceNames(),
|
||||
_ => Enumerable.Empty<string>()
|
||||
};
|
||||
var oldOutputMethod = Config.SoundOutputMethod;
|
||||
var oldDevice = Config.SoundDevice;
|
||||
using var form = new SoundConfig(this, Config, GetDeviceNamesCallback);
|
||||
if (!form.ShowDialog().IsOk()) return;
|
||||
AddOnScreenMessage("Sound settings saved");
|
||||
|
||||
if (form.ApplyNewSoundDevice)
|
||||
AddOnScreenMessage("Sound settings saved");
|
||||
if (Config.SoundOutputMethod == oldOutputMethod && Config.SoundDevice == oldDevice)
|
||||
{
|
||||
Sound.Dispose();
|
||||
Sound = new Sound(Handle, Config, () => Emulator.VsyncRate());
|
||||
Sound.StartSound();
|
||||
Sound.StopSound();
|
||||
}
|
||||
else
|
||||
{
|
||||
Sound.StopSound();
|
||||
Sound.StartSound();
|
||||
Sound.Dispose();
|
||||
Sound = new Sound(Handle, Config, () => Emulator.VsyncRate());
|
||||
}
|
||||
Sound.StartSound();
|
||||
RewireSound();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private bool _programmaticallyChangingValue;
|
||||
|
||||
public bool ApplyNewSoundDevice { get; private set; }
|
||||
|
||||
public IDialogController DialogController { get; }
|
||||
|
||||
public SoundConfig(IDialogController dialogController, Config config, Func<ESoundOutputMethod, IEnumerable<string>> getDeviceNamesCallback)
|
||||
|
@ -69,8 +67,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
DialogController.ShowMessageBox("Buffer size must be at least 60 milliseconds for DirectSound.", "Error", EMsgBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
var oldOutputMethod = _config.SoundOutputMethod;
|
||||
var oldDevice = _config.SoundDevice;
|
||||
_config.SoundEnabled = cbEnableMaster.Checked;
|
||||
_config.SoundEnabledNormal = cbEnableNormal.Checked;
|
||||
_config.SoundEnabledRWFF = cbEnableRWFF.Checked;
|
||||
|
@ -80,7 +76,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
_config.SoundVolume = tbNormal.Value;
|
||||
_config.SoundVolumeRWFF = tbRWFF.Value;
|
||||
_config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>";
|
||||
ApplyNewSoundDevice = _config.SoundOutputMethod != oldOutputMethod || _config.SoundDevice != oldDevice; // read in MainForm at ShowDialog() callsite
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue