Restart Sound in MainForm instead of SoundConfig
This commit is contained in:
parent
edda120b07
commit
bad08162e2
|
@ -908,17 +908,26 @@ namespace BizHawk.Client.EmuHawk
|
|||
ESoundOutputMethod.OpenAL => OpenALSoundOutput.GetDeviceNames(),
|
||||
_ => Enumerable.Empty<string>()
|
||||
};
|
||||
using var form = new SoundConfig(Config, GetDeviceNamesCallback) { Owner = this };
|
||||
if (form.ShowDialog().IsOk())
|
||||
using var form = new SoundConfig(Config, GetDeviceNamesCallback);
|
||||
if (!form.ShowDialog().IsOk())
|
||||
{
|
||||
AddOnScreenMessage("Sound config aborted");
|
||||
return;
|
||||
}
|
||||
|
||||
AddOnScreenMessage("Sound settings saved");
|
||||
if (form.ApplyNewSoundDevice)
|
||||
{
|
||||
Sound.Dispose();
|
||||
Sound = new Sound(Handle);
|
||||
Sound.StartSound();
|
||||
AddOnScreenMessage("Sound settings saved");
|
||||
RewireSound();
|
||||
}
|
||||
else
|
||||
{
|
||||
AddOnScreenMessage("Sound config aborted");
|
||||
Sound.StopSound();
|
||||
Sound.StartSound();
|
||||
}
|
||||
RewireSound();
|
||||
}
|
||||
|
||||
private void AutofireMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
|
@ -851,7 +851,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private GameInfo Game => GlobalWin.Game;
|
||||
|
||||
private Sound Sound => GlobalWin.Sound;
|
||||
private Sound Sound
|
||||
{
|
||||
get => GlobalWin.Sound;
|
||||
set => GlobalWin.Sound = value;
|
||||
}
|
||||
|
||||
public CheatCollection CheatList { get; }
|
||||
|
||||
public (HttpCommunication HTTP, MemoryMappedFiles MMF, SocketServer Sockets) NetworkingHelpers { get; }
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private bool _programmaticallyChangingValue;
|
||||
|
||||
public bool ApplyNewSoundDevice { get; private set; }
|
||||
|
||||
public SoundConfig(Config config, Func<ESoundOutputMethod, IEnumerable<string>> getDeviceNamesCallback)
|
||||
{
|
||||
_config = config;
|
||||
|
@ -80,14 +82,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
_config.SoundVolume = tbNormal.Value;
|
||||
_config.SoundVolumeRWFF = tbRWFF.Value;
|
||||
_config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>";
|
||||
GlobalWin.Sound.StopSound();
|
||||
if (_config.SoundOutputMethod != oldOutputMethod
|
||||
|| _config.SoundDevice != oldDevice)
|
||||
{
|
||||
GlobalWin.Sound.Dispose();
|
||||
GlobalWin.Sound = new Sound(Owner.Handle);
|
||||
}
|
||||
|
||||
ApplyNewSoundDevice = _config.SoundOutputMethod != oldOutputMethod || _config.SoundDevice != oldDevice; // read in MainForm at ShowDialog() callsite
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue