LWJGL Forum

Programming => OpenAL => Topic started by: Cottonwood on February 06, 2011, 11:30:56

Title: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: Cottonwood on February 06, 2011, 11:30:56
My program dies while asking for "ogg sound is playing or not". The only hint I found in the web is in Spanish and seems not to hit the problem exactly:
http://www.javahispano.org/forum/javacup/es/bug_en_visor_opengl/ (http://www.javahispano.org/forum/javacup/es/bug_en_visor_opengl/)

Exception in thread "Thread-5" java.lang.UnsatisfiedLinkError: org.lwjgl.openal.AL10.nalGetSourcei(II)I
   at org.lwjgl.openal.AL10.nalGetSourcei(Native Method)
   at org.lwjgl.openal.AL10.alGetSourcei(AL10.java:881)
   at org.newdawn.slick.openal.SoundStore.isPlaying(SoundStore.java:437)
   at org.newdawn.slick.openal.AudioImpl.isPlaying(AudioImpl.java:73)
   at de.virginiacity.software.JukeSound.playSound(JukeSound.java:77)
   at de.virginiacity.software.MusicPlayer.run(MusicPlayer.java:112)
   at java.lang.Thread.run(Unknown Source)

JukeSound.java:77    while (oggEffect.isPlaying()){

What can I do to solve the problem?
Title: Re: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: broumbroum on February 06, 2011, 11:40:20
check your java library path. It must find the openal dynamic library file.
check what version of lwjgl/slick you're running and maybe get to the latest release. :)
Title: Re: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: Cottonwood on February 06, 2011, 20:29:05
Sorry I've forgotten to tell that the problem occurs very sporadically. Usually the sound works.
Title: Re: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: broumbroum on February 06, 2011, 21:48:57
That's unusual though.
Title: Re: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: Matzon on February 06, 2011, 22:40:43
multiple threads?
Title: Re: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: Cottonwood on February 07, 2011, 00:54:54
My program has some threads. In this part there are two. The player starte always with it's own thread, I think. Meanwhile I prepare the next title

       if (firstRun){
           try {oggEffect = AudioLoader.getAudio("OGG", new FileInputStream("temporary.ogg"));
           } catch (IOException e) {e.printStackTrace();return;}
           firstRun = false;
       }else{
           try {oggEffect1 = AudioLoader.getAudio("OGG", new FileInputStream("temporary.ogg"));
           } catch (IOException e) {e.printStackTrace();return;}
           while (oggEffect.isPlaying()){
               try{Thread.sleep(100);
               } catch (InterruptedException e) {e.printStackTrace();return;}
           }
           oggEffect = oggEffect1;
       }
           oggEffect.playAsMusic(1.0f, 1.0f, false);


But it happend somewhere within a title. At that moment the program must have been in the loop.
Title: Re: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: Matzon on February 07, 2011, 06:34:09
I dont recommend using multiple threads accessing OpenAL. Try to use only 1 thread - specifically, the one that creates the OpenAL context.
Title: Re: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: Cottonwood on February 07, 2011, 14:03:20
Maybe we missunderstand each other. The java program has to create the next sound. Otherwise there will be a long gap between two songs. The second thread ist the sound itselvf.
Title: Re: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: Matzon on February 07, 2011, 17:52:27
I think you need to reorder your stuff a bit :)

Simple games only need 1 thread. You should not sleep while you are playing the 1st sound. Instead the thread should be busy rendering and handling AI, Input and whatnot.

Consider looking at the SoundManager for the space invaders example, which is a fairly simplistic approach, but gets the job done: http://lwjgl.org/wiki/index.php?title=Examples:SpaceInvaders_SoundManager

In this case you'd feed the soundmanager using addSound and then play them when you need to
Title: Re: oggEffect.isPlaying() dies with UnsatisfiedLinkError
Post by: Cottonwood on February 09, 2011, 11:01:20
Thank you for the answer. Sorry, but at the moment I have urgent things to do. I'll come back in a few days.