LWJGL

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [CLOSED] Intermittent "Could not locate OpenAL library"  (Read 7215 times)

Elviz

  • Newbie
  • *
  • Offline Offline
  • Posts: 25
[CLOSED] Intermittent "Could not locate OpenAL library"
« on: March 16, 2010, 07:53:57 »

Setup:
  • Windows XP, 32-bit
  • Sun's JRE 6 Update 18
  • LWJGL 2.3

Calls to AL.create intermittently fail, even though the native library path is correct. In the course of looking for a way to reliably reproduce the problem, I came up with the following test case:

Code: [Select]
import org.lwjgl.*;
import org.lwjgl.openal.*;

public final class AudioTest {
  public static void main(String[] args) {
    for (int idx = 0; idx < 100000; idx++) {
      System.out.println(idx);
     
      try {
        AL.create ();
        AL.destroy();
      } catch (LWJGLException ex) {
        System.err.println(idx);
        ex.printStackTrace();
      }
     
      try {
        Thread.sleep(5);
      } catch (InterruptedException ex) {
      }
    }
  }
}

This just creates and destroys OpenAL instances non-stop. Generally, it works, however, and that's the point, when I click on a button in the Windows taskbar (holding down the mouse) while the program is running, exceptions start occurring:

Code: [Select]
org.lwjgl.LWJGLException: Could not locate OpenAL library.
at org.lwjgl.openal.AL.create(AL.java:153)
at org.lwjgl.openal.AL.create(AL.java:104)
at org.lwjgl.openal.AL.create(AL.java:191)
at AudioTest.main(AudioTest.java:10)

In other words, if the user happens to be switching applications using the taskbar while the LWJGL app is trying to initialize OpenAL, AL.create() will fail and there'll be no sound.
Logged

Matzon

  • Administrator
  • Demigod
  • *****
  • Offline Offline
  • Posts: 2242
Re: Intermittent "Could not locate OpenAL library"
« Reply #1 on: March 16, 2010, 08:36:36 »

In other words, if the user happens to be switching applications using the taskbar while the LWJGL app is trying to initialize OpenAL, AL.create() will fail and there'll be no sound.

strange issue... anywhere on the taskbar?

Elviz

  • Newbie
  • *
  • Offline Offline
  • Posts: 25
Re: Intermittent "Could not locate OpenAL library"
« Reply #2 on: March 16, 2010, 09:53:46 »

strange issue... anywhere on the taskbar?

No, it just happens when clicking on the buttons representing the open applications.

The debug output says:

Failed to load C:\PathToTheNativeBinaries\OpenAL32.dll: Could not open ALC device
Logged

princec

  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 1878
Re: Intermittent "Could not locate OpenAL library"
« Reply #3 on: March 16, 2010, 10:38:03 »

I've noticed this intermittent bug for at least a year now, maybe even longer. It looks like an OpenAL issue but it's hard to be sure.

Cas :)

Matzon

  • Administrator
  • Demigod
  • *****
  • Offline Offline
  • Posts: 2242
Re: Intermittent "Could not locate OpenAL library"
« Reply #4 on: April 05, 2010, 19:58:44 »

I have tracked this issue down to alcOpenDevice failing, if the calling threads process is not the foreground window.
This has to do with using the dsound backend setting the cooperative level using the foreground window (it has no supplied hwnd, and it can't get it).

Code: [Select]
dsound.c:
  hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY);

We cannot reliably fix this - nor can OpenAL.

My best suggestions is to check when OpenAL creation fails, if Display.isActive is false too - then thats probably the reason.

You could then busy wait or notify the user... at any rate, its probably not something we can fix internally in lwjgl.

Elviz

  • Newbie
  • *
  • Offline Offline
  • Posts: 25
Re: Intermittent "Could not locate OpenAL library"
« Reply #5 on: April 07, 2010, 14:55:20 »

Yeah, perhaps I'll use some kind of workaround.

Thanks for looking into this.
Logged

princec

  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 1878
Re: Intermittent "Could not locate OpenAL library"
« Reply #6 on: April 08, 2010, 10:23:23 »

Basically then - it can probably be retried and will probably work eventually when the window gets into the foreground?

Cas :)

Matzon

  • Administrator
  • Demigod
  • *****
  • Offline Offline
  • Posts: 2242
Re: Intermittent "Could not locate OpenAL library"
« Reply #7 on: April 08, 2010, 10:34:56 »

yes - but if the user is doing something else - then you'd be busy waiting until then...
You could probably also wait to create AL until you get the first mouse input?