Fix exception when stopping non-cached audio stream

This commit is contained in:
shadowislord 2014-11-27 11:51:45 -05:00
parent 44db44ee56
commit c7b6445a35
2 changed files with 12 additions and 1 deletions

View File

@ -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) {

View File

@ -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();
}
}
}
}