If dummy sound chosen in config, try DirectSound (maybe fixes #3379)

- if DirectSound fails (i.e. dummy is in config for a reason), then skip the
error dialog as the user has probably seen it already, and set it back to dummy
- if DirectSound succeeds, leave it, it will be written to config (there's a
mute setting for people who really don't want sound)
- copied the init config code so s/DirectSound/OpenAL/ on Linux
- could probably try OpenAL on Windows when DirectSound fails but whatever
This commit is contained in:
YoshiRulz 2022-09-08 08:36:47 +10:00
parent 707ec53bd5
commit d2965c2185
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 10 additions and 6 deletions

View File

@ -497,20 +497,24 @@ namespace BizHawk.Client.EmuHawk
InputManager.ResetMainControllers(_autofireNullControls);
InputManager.AutofireStickyXorAdapter.SetOnOffPatternFromConfig(Config.AutofireOn, Config.AutofireOff);
var savedOutputMethod = Config.SoundOutputMethod;
if (savedOutputMethod is ESoundOutputMethod.Dummy) Config.SoundOutputMethod = HostCapabilityDetector.HasDirectX ? ESoundOutputMethod.DirectSound : ESoundOutputMethod.OpenAL;
try
{
Sound = new Sound(Handle, Config, () => Emulator.VsyncRate());
}
catch
{
string message = "Couldn't initialize sound device! Try changing the output method in Sound config.";
if (Config.SoundOutputMethod == ESoundOutputMethod.DirectSound)
if (savedOutputMethod is not ESoundOutputMethod.Dummy)
{
message = "Couldn't initialize DirectSound! Things may go poorly for you. Try changing your sound driver to 44.1khz instead of 48khz in mmsys.cpl.";
ShowMessageBox(
owner: null,
text: savedOutputMethod is ESoundOutputMethod.DirectSound
? "Couldn't initialize DirectSound! Things may go poorly for you. Try changing your sound driver to 44.1khz instead of 48khz in mmsys.cpl."
: "Couldn't initialize sound device! Try changing the output method in Sound config.",
caption: "Initialization Error",
EMsgBoxIcon.Error);
}
ShowMessageBox(owner: null, message, "Initialization Error", EMsgBoxIcon.Error);
Config.SoundOutputMethod = ESoundOutputMethod.Dummy;
Sound = new Sound(Handle, Config, () => Emulator.VsyncRate());
}