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

@ -192,6 +192,10 @@ public class AudioStream extends AudioData implements Closeable {
} }
} }
public boolean isSeekable() {
return in instanceof SeekableStream;
}
public void setTime(float time) { public void setTime(float time) {
if (in instanceof SeekableStream) { if (in instanceof SeekableStream) {
((SeekableStream) in).setTime(time); ((SeekableStream) in).setTime(time);

View File

@ -1047,7 +1047,14 @@ public class ALAudioRenderer implements AudioRenderer, Runnable {
freeChannel(chan); freeChannel(chan);
if (src.getAudioData() instanceof AudioStream) { 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();
}
} }
} }
} }