TASEmulators / TASEmulators/BizHawk

The client hangs and crashes when connecting a Bluetooth headset while BizHawk is running.

Open
#4,687 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

App: EmuHawk Repro: Affects 2.11.1 dev Repro: Could not reproduce
Dominant language
C#
Stars
2.8k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

The client hangs and crashes when connecting a Bluetooth headset while BizHawk is running. It seems like the XAudio2 output provider fails to handle the device change/invalidation gracefully, leading to a SharpGenException.

Repro
Start BizHawk (EmuHawk) using the XAudio2 Sound Output provider.

Load any ROM and start emulation.

Turn on or connect a Bluetooth headset.

Set the Bluetooth headset as the default playback device in Windows (or wait for Windows to switch to it automatically).

BizHawk hangs and displays an error dialog.

Output

SharpGen.Runtime.SharpGenException: HRESULT: [0x88960004], Module: [Vortice.XAudio2], ApiCode: [XAUDIO2_E_DEVICE_INVALIDATED/DeviceInvalidated]
   vid SharpGen.Runtime.Result.ThrowFailureException()
   vid Vortice.XAudio2.IXAudio2.CreateMasteringVoice(Int32 inputChannels, Int32 inputSampleRate, Int32 flags, String szDeviceId, Nullable`1 effectChain, AudioStreamCategory streamCategory)
   vid Vortice.XAudio2.IXAudio2.CreateMasteringVoice(Int32 inputChannels, Int32 inputSampleRate, AudioStreamCategory category, String deviceId, EffectDescriptor[] effectDescriptors)
   vid BizHawk.Bizware.Audio.XAudio2SoundOutput.ResetToDefaultDeviceIfNeeded() i /src/BizHawk.Bizware.Audio/XAudio2SoundOutput.cs:rad 125
   vid BizHawk.Bizware.Audio.XAudio2SoundOutput.CalculateSamplesNeeded() i /src/BizHawk.Bizware.Audio/XAudio2SoundOutput.cs:rad 136
   vid BizHawk.Client.EmuHawk.Sound.UpdateSound(Single atten, Boolean isSecondaryThrottlingDisabled) i /src/BizHawk.Client.EmuHawk/Sound/Sound.cs:rad 170
   vid BizHawk.Client.EmuHawk.MainForm.StepRunLoop_Core(Boolean force) i /src/BizHawk.Client.EmuHawk/MainForm.cs:rad 3111
   vid BizHawk.Client.EmuHawk.MainForm.ProgramRunLoop() i /src/BizHawk.Client.EmuHawk/MainForm.cs:rad 1007
   vid BizHawk.Client.EmuHawk.Program.SubMain(String[] args) i /src/BizHawk.Client.EmuHawk/Program.cs:rad 384

Host env.
BizHawk 227bb47d7f1ef854c2ba99d0cac2c7693c845fd2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with BizHawk.Bizware.Audio/XAudio2SoundOutput.cs, especially ResetToDefaultDeviceIfNeeded() at line 125 and CalculateSamplesNeeded() at line 136, then trace the call from Sound.UpdateSound(). Reproduce the device switch with the XAudio2 provider and verify that connecting or selecting a Bluetooth headset no longer hangs or crashes with XAUDIO2_E_DEVICE_INVALIDATED.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.