Hello Guest

[BUG] Issue with changing sound device on Linux for Minecraft Java Edition

  • 3 Replies
Hello, I'm hoping you may be able to shed some light on this. 

I'm having an issue when I'm running Minecraft Java Edition 1.16.3 on Linux Mint 19, that I am not able to change the audio device in Pulse Audio.  This seems to be a known issue.  For details see this Mojang bug:  https://bugs.mojang.com/browse/MC-26748

They are saying it is a LWJGL issue, which they cannot control.  I can't see anything logged for that - can you please confirm?

The workaround is to downgrade to LWJGL 2.8.0, but this seems like a really old version, and the method for doing this doesn't seem to work anymore. 

I'm wondering if there is a newer version of LWJGL 3.x that will work with Minecraft to allow switching the audio device.  The current version updating with Minecraft Java Edition 1.16.3 is 3.2.3.

For details on what I've tried, and more information on the issue, see this thread:  https://forums.linuxmint.com/viewtopic.php?f=47&t=331982&p=1898021#p1898021


Offline spasi

  • *****
  • 2206
    • WebHotelier
You're wasting your time with trying different Java and LWJGL versions. The issue has nothing to do with Java, LWJGL or even Linux. An application (Minecraft) uses a Java library (LWJGL) that provides bindings to a native library (OpenAL Soft) that handles everything related to audio. The JVM is nowhere in the equation and the LWJGL bindings are extremely simple and don't affect anything. You have to look at what OpenAL Soft does and how Minecraft uses it (via the API defined in the OpenAL specification).

The simplest way to use OpenAL Soft is to open the default audio device. However, it does not (and never did) track the current default audio device and does not automatically switch to it when it changes. This applies to Linux, Windows, everywhere. Downgrading to LWJGL 2.8.0 can't (and won't) fix anything. It's simply not how OpenAL Soft works. Switching to a different device requires recreation of the OpenAL context and all related components and that's something that only the application developer can handle. So yeah, the blame game doesn't end here and the finger points back to Minecraft developers.

(Btw, Minecraft developers have (almost) never contacted LWJGL maintainers to ask questions or request changes. They shouldn't need to either. In this case for example, they should contact the OpenAL Soft maintainers for audio related issues.)

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.

In the meantime, you could try fixing this with a virtual audio device. I'm not sure what's available on Linux/PulseAudio, but it's certainly possible on Windows. You create a virtual audio device and configure it as the default. It's what Minecraft/OpenAL Soft will use to output audio. Then you configure the virtual device to forward any audio to the real audio device of your choice. You should then be able to change the downstream device, on the fly, without breaking Minecraft/OpenAL Soft.

Thanks for the detailed response.  I have a ticket open with Mojang, and I will provide this information. 

I don't have a problem with Minecraft not allowing you to specify the audio devices, as long as control via the OS works.  I do agree though - most games have the option to select the "Default" audio device, or select it manually.