getBuffer method
Get a buffer.
Implementation
Buffer getBuffer(final AssetReference reference) {
final file = reference.getFile(random);
var buffer = _buffers[file.path];
if (buffer == null) {
if (!file.existsSync()) {
throw NoSuchBufferError(file);
}
final encryptionKey = reference.encryptionKey;
if (encryptionKey == null) {
buffer = Buffer.fromFile(synthizer, file);
} else {
final data = decryptFileBytes(file: file, encryptionKey: encryptionKey);
buffer = Buffer.fromBytes(synthizer, data);
}
_size += buffer.size;
while (size > maxSize && _files.isNotEmpty) {
prune();
}
_files.add(file.path);
_buffers[file.path] = buffer;
}
return buffer;
}