use of de.jarnbjo.ogg.LogicalOggStream in project jmonkeyengine by jMonkeyEngine.
the class OGGLoader method load.
private AudioData load(InputStream in, boolean readStream, boolean streamCache) throws IOException {
if (readStream && streamCache) {
oggStream = new CachedOggStream(in);
} else {
oggStream = new UncachedOggStream(in);
}
Collection<LogicalOggStream> streams = oggStream.getLogicalStreams();
loStream = streams.iterator().next();
// if (loStream == null){
// throw new IOException("OGG File does not contain vorbis audio stream");
// }
vorbisStream = new VorbisStream(loStream);
streamHdr = vorbisStream.getIdentificationHeader();
if (!readStream) {
AudioBuffer audioBuffer = new AudioBuffer();
audioBuffer.setupFormat(streamHdr.getChannels(), 16, streamHdr.getSampleRate());
audioBuffer.updateData(readToBuffer());
return audioBuffer;
} else {
AudioStream audioStream = new AudioStream();
audioStream.setupFormat(streamHdr.getChannels(), 16, streamHdr.getSampleRate());
// might return -1 if unknown
float streamDuration = computeStreamDuration();
audioStream.updateData(readToStream(oggStream.isSeekable()), streamDuration);
return audioStream;
}
}
Aggregations