[SOLVED] Exception: Could not locate OpenAL library

I tried this work around. Create a java project and edit the file LwjglAbstractDisplay.java. Go to line 211 in the run method. Add the following lines:

    while(true) {
        try {
            if (!initInThread()) {
                logger.log(Level.SEVERE, "Display initialization failed. Cannot continue.");
                return;
            }
        } catch (Exception ex) {
            System.out.println("LwjglAbstractDisplay: initInThread() call new.");
            try { Thread.sleep(1000); } catch (Exception ex2) {}
            continue;
        }
        break;
    }

create a new library: jme3-lwjgl-3.2.1-stable.jar.
if an exception occurs, the output looks like this:

Jul 26, 2020 11:12:08 AM com.jme3.asset.AssetConfig loadText
WARNUNG: Cannot find loader com.jme3.scene.plugins.blender.BlenderModelLoader
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80004005
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80004005
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80004005
LwjglAbstractDisplay: initInThread() call new.
Jul 26, 2020 11:12:09 AM com.jme3.system.lwjgl.LwjglContext printContextInitInfo

Thanks for your help :slight_smile:

1 Like

The exception is thrown from main.start() - restarting the context or application results in the same failure. Setting the appSettings to showSettings true/false doesn’t make any difference either. Trying as hard as I can to ensure the window is focused doesn’t make any difference - or I just can’t physically do it quick enough.

The only information I have really to go on after reading through the data in this post is that

  • it may be a race condition
  • the sound card is “busy”.

For the second point - does that mean that no spare channels are available? It requires exclusive access and can’t obtain it? I’m not sure exactly what “busy” means. It exists (I have a sound card). It works (in any other application). I have been listening to youtube/watching videos and run a JME app previously with no issues - so it shouldn’t require “exclusive” access.

I’m still none the wiser at this point.

I think maybe it wasn’t 100% clear from your post. Did the work around work?

1 Like

yes, the work around works very well. This solves my problem.

1 Like

Note: for a real solution, we probably want to limit the number of times that it loops.

1 Like

I agree.

I’ve opened issue 1383 to track the fix.

3 Likes

Hi,
Same problem here with an Ubuntu 20.04 machine. The issue was solved following instructions on this URL:

1 Like

I’ve implemented a workaround for LWJGL v2 in an “sgold-issue-1383” branch at https://github.com/stephengold/jmonkeyengine/tree/sgold-issue-1383

Before submitting a PR, I’d like to implement a similar fix for LWJGL v3. To do so, I need to see a stack trace from a failing run with LWJGL v3. I looked through past discussions and didn’t find one. Can anyone provide a stack trace for this issue with LWJGL v3?

1 Like

I’ll just fix LWJGL v2, then.

PR 1432

3 Likes

PR 1432 is ready for testing, but has not been integrated yet.

@thomas1, @ItsMike54, @tlf30, @Etherblood, @jayfella, and anyone else who can reliably reproduce this issue:

3 Likes

I never used gradle before and don’t see a pom for maven, do you know whether there is an easy way to test it with maven (preferably like including maven projects directly from github with jitpack)? Otherwise i’ll probably have to figure out gradle…
Also, I assume that the fix probably won’t work for me, since I had no audio device plugged at all in my case, but I could be wrong.
Thx so far.^^

I’m also interested in what happens when there’s no audio device.

You’ll need Gradle in order to build JMonkeyEngine: Gradle | Installation

Then, assuming you use bash:

  • export JAVA_HOME=" path to your JDK "
  • git clone https://github.com/stephengold/jmonkeyengine.git
  • cd jmonkeyengine
  • git checkout sgold-issue-1383
  • ./gradlew assemble
  • ./gradlew run --console=plain

If you reach the test chooser, I suggest selecting “TestAmbient”, since that test includes audio.

1 Like

And if he’s running with gradlew then there is no need to install gradle first.

1 Like

Alright, it took me a while to get running since my jdk13 installation caused a “Unsupported class file major version 57” exception during the assemble.
Audio worked fine after I switched to jdk11 with boxes plugged in.
Then i tried again after unplugging them and it crashed.
I did not restart the test selection between both runs with & without audio, so this are the logs for both:

> Task :jme3-examples:run
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jme3.util.ReflectionAllocator (file:/C:/Users/Philipp/Documents/GitHub/stephengold/jmonkeyengine/jme3-core/build/libs/jme3-core-3.3.0-SNAPSHOT.jar) to method sun.nio.ch.DirectBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of com.jme3.util.ReflectionAllocator
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Nov. 25, 2020 8:34:57 NACHM. com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.3.0-SNAPSHOT
 * Branch: sgold-issue-1383
 * Git Hash: b546358
 * Build Date: 2020-11-25
Nov. 25, 2020 8:34:58 NACHM. com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_93eff437a314841a\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_93eff437a314841a\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_93eff437a314841a\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_93eff437a314841a\nvldumdx.dll
 * Driver Version: null
 * Scaling Factor: 1
Nov. 25, 2020 8:34:58 NACHM. com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GTX 750/PCIe/SSE2
 * OpenGL Version: 4.6.0 NVIDIA 441.12
 * GLSL Version: 4.60 NVIDIA
 * Profile: Compatibility
Nov. 25, 2020 8:34:58 NACHM. com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Nov. 25, 2020 8:34:58 NACHM. com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
Nov. 25, 2020 8:34:58 NACHM. com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Nov. 25, 2020 8:34:58 NACHM. com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4
Nov. 25, 2020 8:35:15 NACHM. com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_93eff437a314841a\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_93eff437a314841a\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_93eff437a314841a\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nv_dispi.inf_amd64_93eff437a314841a\nvldumdx.dll
 * Driver Version: null
 * Scaling Factor: 1
Nov. 25, 2020 8:35:15 NACHM. com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GTX 750/PCIe/SSE2
 * OpenGL Version: 4.6.0 NVIDIA 441.12
 * GLSL Version: 4.60 NVIDIA
 * Profile: Compatibility
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
Nov. 25, 2020 8:35:15 NACHM. com.jme3.audio.lwjgl.LwjglALC createALC
WARNING: Caught an LWJGLException from AL.create(). Will retry after 100 msec, with 3 more retries remaining.

AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
Nov. 25, 2020 8:35:15 NACHM. com.jme3.audio.lwjgl.LwjglALC createALC
WARNING: Caught an LWJGLException from AL.create(). Will retry after 300 msec, with 2 more retries remaining.

AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
Nov. 25, 2020 8:35:16 NACHM. com.jme3.audio.lwjgl.LwjglALC createALC
WARNING: Caught an LWJGLException from AL.create(). Will retry after 900 msec, with 1 more retry remaining.

AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
Nov. 25, 2020 8:35:16 NACHM. com.jme3.audio.lwjgl.LwjglALC createALC
WARNING: Caught an LWJGLException from AL.create(). Will retry after 2700 msec, with 0 more retries remaining.

AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
AL lib: (EE) MMDevApiOpenPlayback: Device init failed: 0x80070490
Nov. 25, 2020 8:35:19 NACHM. com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,6,main]
java.lang.RuntimeException: org.lwjgl.LWJGLException: Could not locate OpenAL library.
        at com.jme3.audio.lwjgl.LwjglALC.createALC(LwjglALC.java:32)
        at com.jme3.audio.openal.ALAudioRenderer.initOpenAL(ALAudioRenderer.java:95)
        at com.jme3.audio.openal.ALAudioRenderer.initialize(ALAudioRenderer.java:226)
        at com.jme3.app.LegacyApplication.initAudio(LegacyApplication.java:290)
        at com.jme3.app.LegacyApplication.initialize(LegacyApplication.java:627)
        at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:198)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:136)
        at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:218)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.lwjgl.LWJGLException: Could not locate OpenAL library.
        at org.lwjgl.openal.AL.create(AL.java:156)
        at org.lwjgl.openal.AL.create(AL.java:102)
        at org.lwjgl.openal.AL.create(AL.java:206)
        at com.jme3.audio.lwjgl.LwjglALC.createALC(LwjglALC.java:27)
        ... 8 more
2 Likes

As expected, it retried 4 times, then crashed with a stack trace. Thanks for your help, @Etherblood!

I’m still hoping to hear back from someone who’s seen the issue with working audio …

4 Likes

After some basic testing with TestAmbient.java,

Audio seems to work fine with an audio device when it starts, but afterwards crashes.
Without an audio device, the app crashes immediately before audio begins playing.

Error:

OpenGLException: Invalid enum (1280)

Trace:

org.lwjgl.opengl.OpenGLException: Invalid enum (1280)
	at org.lwjgl.opengl.Util.checkGLError(Util.java:59)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.checkGLError(LwjglAbstractDisplay.java:142)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:163)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:196)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:239)
	at java.base/java.lang.Thread.run(Thread.java:834)
1 Like

Not what I was expecting. This was with assertions enabled?

Hmm, please refresh my memory on how to check if assertions are enabled.

1 Like

If you invoke Java at the command line, you’d enable assertions with the “-ea” switch.

If you run the application via Gradle, there’d probably be enableAssertions true in the JavaExec runtime options. In the jmonkeyengine project, this setting is in “jme3-examples/build.gradle” and it is controlled by a setting in “jme3-examples/gradle.properties”.

If still in doubt, you can test whether assertions are enabled at runtime:

boolean enabled = false;
assert enabled = true; // Note: intentional side effect.
if (enabled) {
    System.out.println("Assertions are enabled.");
} else {
    System.out.println("Assertions are disabled.");
}
1 Like

Thanks!
Yes, assertions are enabled by default (I am testing with Gradle).

1 Like