LWJGL
June 19, 2013, 20:45:42 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.9.0 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: Why does this audio setPosition() not work?  (Read 2116 times)
Cottonwood
Regular nerd
**
Posts: 50



WWW
« on: January 22, 2011, 13:55:54 »

I could abstract the problem to two lines of code:
Code:
import java.io.FileInputStream;
import java.io.IOException;
import org.lwjgl.openal.AL;
import org.newdawn.slick.openal.Audio;
import org.newdawn.slick.openal.AudioLoader;

public class JukeOggTester {

public static boolean positioned;
private static Audio oggEffect;

public static void main(String[] args)
{
try {oggEffect = AudioLoader.getAudio("OGG",
new FileInputStream("Barry Ryan - Eloise.ogg"));
} catch (IOException e) {e.printStackTrace();AL.destroy();return;}
System.out.println("before setPosition");
positioned = oggEffect.setPosition(100f);
System.out.println("after setPosition");
AL.destroy();
}
The try... is working. Why dies the setPosition with OpenAL error: Invalid Name (40961)?
Code:
Sat Jan 22 22:47:21 CET 2011 INFO:Initialising sounds..
Sat Jan 22 22:47:22 CET 2011 INFO:- Sound works
Sat Jan 22 22:47:22 CET 2011 INFO:- 64 OpenAL source available
Sat Jan 22 22:47:22 CET 2011 INFO:- Sounds source generated
before setPosition
Exception in thread "main" org.lwjgl.openal.OpenALException: OpenAL error: Invalid Name (40961)
at org.lwjgl.openal.Util.checkALError(Util.java:64)
at org.lwjgl.openal.AL10.alSourcef(AL10.java:836)
at org.newdawn.slick.openal.AudioImpl.setPosition(AudioImpl.java:125)
at de.virginiacity.software.JukeOggTester.main(JukeOggTester.java:20)
Logged

Regards. Cottonwood.
hugheth
Newbie
*
Posts: 1


« Reply #1 on: April 18, 2012, 13:46:28 »

Hello, I just run in to this problem too, so I'm resurrecting this thread in case anyone else ever runs into the problem

You need to add the line:

Code:
if (index == -1) return false;

at the top of the setPosition function of the class org.newdawn.slick.openal.Audio

ending up with:

Code:
public boolean setPosition(float position) {
if (index == -1) return false;

position = position % length;

AL10.alSourcef(store.getSource(index), AL11.AL_SEC_OFFSET, position);
if (AL10.alGetError() != 0) {
return false;
}
return true;
}

For some reason the "index" property isn't checked, even in the latest release of Slick2d (I'll comment on their forums asking for a bug fix)
Logged
Pages: [1]
  Print  
 
Jump to:  

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