LWJGL
October 31, 2014, 23:40:21 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.9.1 released!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: [CLOSED] Intermittent "Could not locate OpenAL library"  (Read 7088 times)
Elviz
Newbie
*
Posts: 25


« on: March 16, 2010, 00: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:
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:
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
*****
Posts: 2242



« Reply #1 on: March 16, 2010, 01: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?
Logged

Elviz
Newbie
*
Posts: 25


« Reply #2 on: March 16, 2010, 02: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
*****
Posts: 1878



WWW
« Reply #3 on: March 16, 2010, 03: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 Smiley
Logged

Matzon
Administrator
Demigod
*****
Posts: 2242



« Reply #4 on: April 05, 2010, 12: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:
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.
Logged

Elviz
Newbie
*
Posts: 25


« Reply #5 on: April 07, 2010, 07:55:20 »

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

Thanks for looking into this.
Logged
princec
Nerdus Imperius
*****
Posts: 1878



WWW
« Reply #6 on: April 08, 2010, 03:23:23 »

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

Cas Smiley
Logged

Matzon
Administrator
Demigod
*****
Posts: 2242



« Reply #7 on: April 08, 2010, 03: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?
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!