Fractal Softworks Forum

Starsector => Bug Reports & Support => Topic started by: Gothars on November 12, 2020, 02:00:55 PM

Title: Audio doesn't work after bluetooth disconnect
Post by: Gothars on November 12, 2020, 02:00:55 PM
If my bluetooth headphones get disconnected, either manually or by distance, Starsector audio stops working. Other sources still play audio normally, either over reconnected bluetooth or normal speakers. Starsector needs a restart, though.
Title: Re: Audio doesn't work after bluetooth disconnect
Post by: Alex on November 16, 2020, 12:04:22 PM
Sorry about the delayed response! Got a bit sidetracked.

This is a known issue, unfortunately - the game can't handle the audio output changing after startup. I've tried some of the more obvious things as far as re-initializing its audio (though detecting when it actually needs to do it would be another hurdle), but it hasn't worked, and I haven't had the time to really dig into it. Plus, my familiarity with the underlying sound API is fairly low, so it'd be a significant effort to try to figure out, with no guarantee that it's actually possible using the stuff the game is using (i.e. LWJGL + OpenAL).
Title: Re: Audio doesn't work after bluetooth disconnect
Post by: Gothars on November 16, 2020, 03:37:12 PM
Ah ok thanks, it's no big deal.
Title: Re: Audio doesn't work after bluetooth disconnect
Post by: Curator on March 29, 2021, 07:51:56 AM
Sorry about the delayed response! Got a bit sidetracked.

This is a known issue, unfortunately - the game can't handle the audio output changing after startup. I've tried some of the more obvious things as far as re-initializing its audio (though detecting when it actually needs to do it would be another hurdle), but it hasn't worked, and I haven't had the time to really dig into it. Plus, my familiarity with the underlying sound API is fairly low, so it'd be a significant effort to try to figure out, with no guarantee that it's actually possible using the stuff the game is using (i.e. LWJGL + OpenAL).

Hey. Just got the same issue when changing my audio output from speakers to bluetooth headphones.
Some googling leads to Minecraft that uses LWJGL + OpenAL too. Here are some steps that Minecraft devs do to solve this ( http://forum.lwjgl.org/index.php?topic=7081.0 ):

What could be done to resolve this? Suggestions:
- Minecraft regularly queries alcGetInteger(device, ALC_CONNECTED), via the ALC_EXT_disconnect extension. If it returns ALC_FALSE, it automatically recreates the audio context.
- Minecraft regularly queries alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER). This returns a string that describes the default audio device. If it changes, it automatically recreates the audio context.
- Minecraft queries ALC_ALL_DEVICES_SPECIFIER (also regularly updates it) and displays the list of available audio devices. Instead of changing the default audio device from the OS settings, users can change the audio device used by Minecraft itself. This is the simplest and most robust solution. I don't remember a PC game that doesn't have such an option in its audio settings.