use of com.jme3.asset.plugins.AndroidLocator.AndroidAssetInfo in project jmonkeyengine by jMonkeyEngine.
the class NativeVorbisLoader method loadStream.
private static AudioStream loadStream(AssetInfo assetInfo) throws IOException {
AndroidAssetInfo aai = (AndroidAssetInfo) assetInfo;
AssetFileDescriptor afd = null;
NativeVorbisFile file = null;
boolean success = false;
try {
afd = aai.openFileDescriptor();
int fd = afd.getParcelFileDescriptor().getFd();
file = new NativeVorbisFile(fd, afd.getStartOffset(), afd.getLength());
AudioStream stream = new AudioStream();
stream.setupFormat(file.channels, 16, file.sampleRate);
stream.updateData(new VorbisInputStream(afd, file), file.duration);
success = true;
return stream;
} finally {
if (!success) {
if (file != null) {
file.close();
}
if (afd != null) {
afd.close();
}
}
}
}
use of com.jme3.asset.plugins.AndroidLocator.AndroidAssetInfo in project jmonkeyengine by jMonkeyEngine.
the class NativeVorbisLoader method loadBuffer.
private static AudioBuffer loadBuffer(AssetInfo assetInfo) throws IOException {
AndroidAssetInfo aai = (AndroidAssetInfo) assetInfo;
AssetFileDescriptor afd = null;
NativeVorbisFile file = null;
try {
afd = aai.openFileDescriptor();
int fd = afd.getParcelFileDescriptor().getFd();
file = new NativeVorbisFile(fd, afd.getStartOffset(), afd.getLength());
ByteBuffer data = BufferUtils.createByteBuffer(file.totalBytes);
file.readFully(data);
AudioBuffer ab = new AudioBuffer();
ab.setupFormat(file.channels, 16, file.sampleRate);
ab.updateData(data);
return ab;
} finally {
if (file != null) {
file.close();
}
if (afd != null) {
afd.close();
}
}
}
Aggregations