Hi. I get this exception sometimes when playing sounds:
[java]Exception in thread “LWJGL Renderer Thread” java.lang.ArrayIndexOutOfBoundsException: -1
at com.jme3.audio.lwjgl.LwjglAudioRenderer.clearChannel(LwjglAudioRenderer.java:405)
at com.jme3.audio.lwjgl.LwjglAudioRenderer.playSource(LwjglAudioRenderer.java:562)[/java]
Currently don’t have any more info than this, but i’ll update the thread if i find out something.
When playing several sounds at once (more than 16?), getChannel() comes back with -1 as channel index (no free channels).
In playSourceInstance(), there is a check for this, and it returns if it’s -1. playSource() does not have this check.
I don’t know if it’s intended, or not, but it seems to be causing the exception.
Yeah, theres some quirks in the sound system still… We want to redo it anyway.
We should probably just return if we get -1 for the channel, so its possible to fix this
Also we might want to increase the # of channels, since OpenAL Soft does its own mixing anyway we are not limited in any way by number of channels.
Agreed Momoko. Could we get this committed?
[java]Index: LwjglAudioRenderer.java
===================================================================
— LwjglAudioRenderer.java (revision 371)
+++ LwjglAudioRenderer.java (working copy)
@@ -292,8 +292,10 @@
if (audioDisabled)
return;
-
assert src.getChannel() >= 0;<br />
-
-
if (src.getChannel() < 0){<br />
-
return;<br />
-
}<br />
+
int id = channels[src.getChannel()];
switch (param){
case Position:
[/java]
…
Your post is 3 months late and also after I fixed this issue.
Your fix does nothing because if updateAudioParam is called that means renderer is set on the source, and if renderer is set, then the channel is not -1. It’s a logical impossibility unless you call updateAudioParam or setChannel manually and so it should remain an assertion.
Interesting. Well all I can say is that the current nightly build crashes on me alot with this error if I don’t apply this fix myself.
Perhaps you’re calling updateAudioParam or setChannel?