this testcase when pressing LMB twice such that it attempts to play() while not yet stopped causes:
Caused by: java.lang.AssertionError
at com.jme3.audio.lwjgl.LwjglAudioRenderer.playSource(LwjglAudioRenderer.java:843)
at com.jme3.audio.AudioNode.play(AudioNode.java:164)
at org.jme3.tests.HelloAudio2$1.play_aroundBody4(HelloAudio2.java:171)
at org.jme3.tests.HelloAudio2$1$AjcClosure5.run(HelloAudio2.java:1)
at org.aspectj.ExceptionsHandling.ThrowWrapper.ajc$around$org_aspectj_ExceptionsHandling_ThrowWrapper$1$495fa4ebproceed(ThrowWrapper.aj:1)
at org.aspectj.ExceptionsHandling.ThrowWrapper.ajc$around$org_aspectj_ExceptionsHandling_ThrowWrapper$1$495fa4eb(ThrowWrapper.aj:281)
... 11 more
to get this must have assertions enabled ie vm arg "-ea"
first seen
here
The assertion checks if the audio node is stopped … Obviously it won’t be if the AudioNode is already playing.
Does the code still work with assertions disabled?
1 Like
it works indeed. I was assuming the assert is wrong like that but I suppose in whatever tests(imagining junit ones) are done for the nightly builds(if any) there won’t be a play() called twice or before the previous ones finishes playing
fair enough I guess 
[java]public void playSource(AudioNode src) {
checkDead();
synchronized (threadLock){
while (!threadLock.get()){
try {
threadLock.wait();
} catch (InterruptedException ex) {
}
}
if (audioDisabled)
return;
assert src.getStatus() == Status.Stopped || src.getChannel() == -1;
if (src.getStatus() == Status.Playing){
return;
}else if (src.getStatus() == Status.Stopped){
// allocate channel to this source
int index = newChannel();
if (index == -1) {
logger.log(Level.WARNING, “No channel available to play {0}”, src);
return;
}
clearChannel(index);
src.setChannel(index);
AudioData data = src.getAudioData();
if (data.isUpdateNeeded())
updateAudioData(data);
chanSrcs[index] = src;
setSourceParams(channels[index], src, false);
attachAudioToSource(channels[index], data);
}
alSourcePlay(channels[src.getChannel()]);
src.setStatus(Status.Playing);
}
}[/java]
Okay I removed the assertion