Here is a bit of the source:
public class Sound extends Point {
...
public Sound(String name) {
...
source = alGenSources();
alSourcei(source, AL_BUFFER, buffers.get(name));
alDeleteSources(source);
source = alGenSources();
alSourcei(source, AL_BUFFER, buffers.get(name));
setDistanceModel(INVERSE);
setDirection(0);
int error = alGetError();
if (error != AL_NO_ERROR) {
throw new RGException(RGException.SOUND, alGetString(error));
}
}
...
public void destroy() {
alDeleteSources(source);
}
But when I create a sound with the file “laser.wav”, then let it play (let it go, let it go), then destroy it, then create another sound with “laser.wav”… It throws this error:
Exception in thread "main" com.redmintie.redgame.core.RGException: [SOUND] Invalid Name
I had a look into it and this error is caused by:
alSourcei(source, AL_BUFFER, buffers.get(name));
Is OpenAL deleting the buffer? Does anybody know what is happening? Sry for so much code… I tried recreating it in a simpler version but I wasn’t able to… also, this is my first time trying OpenAL (it is amazing btw)
Thx in advance…
EDIT: just found out that you don’t actually have to let the sound play out… even if you don’t let it play out or dont event start it playing at all… It will still create the same error