Fix exception when stopping non-cached audio stream

experimental
shadowislord 10 years ago
parent 44db44ee56
commit c7b6445a35
  1. 4
      jme3-core/src/main/java/com/jme3/audio/AudioStream.java
  2. 9
      jme3-core/src/main/java/com/jme3/audio/openal/ALAudioRenderer.java

@ -191,6 +191,10 @@ public class AudioStream extends AudioData implements Closeable {
throw new RuntimeException("AudioStream is already closed!");
}
}
public boolean isSeekable() {
return in instanceof SeekableStream;
}
public void setTime(float time) {
if (in instanceof SeekableStream) {

@ -1047,7 +1047,14 @@ public class ALAudioRenderer implements AudioRenderer, Runnable {
freeChannel(chan);
if (src.getAudioData() instanceof AudioStream) {
((AudioStream)src.getAudioData()).setTime(0);
// If the stream is seekable, then rewind it.
// Otherwise, close it, as it is no longer valid.
AudioStream stream = (AudioStream)src.getAudioData();
if (stream.isSeekable()) {
stream.setTime(0);
} else {
stream.close();
}
}
}
}

Loading…
Cancel
Save