add method
Add a chunk of bytes, decoding any complete frames.
Throws StateError if the codec stalls with a full buffer.
Implementation
void add(List<int> chunk, void Function(FrameBorrowedView frame) onFrame) {
final Uint8List bytes =
chunk is Uint8List ? chunk : Uint8List.fromList(chunk);
var off = 0;
while (off < bytes.length) {
final wrote = _rb.write(bytes, off, bytes.length - off);
if (wrote != 0) {
off += wrote;
} else {
_decodeOneOrThrow(onFrame);
}
_drain(onFrame);
}
}