pullChunkBytes method
Pulls a chunk of a string stream as raw bytes.
The binary counterpart of pullChunk (via lsl_pull_chunk_buf).
liblsl keeps pulling until maxSamples samples have been read or
timeout expires, so a nonzero timeout with a maxSamples larger
than what arrives always waits the full timeout. Use timeout: 0.0
to take only what is already buffered.
Implementation
Future<LSLChunk<Uint8List>> pullChunkBytes({
int maxSamples = 512,
double timeout = 0.0,
}) async {
if (!_useIsolates) {
return _pullChunkBytesDirect(maxSamples, timeout);
}
final buf = _binaryChunkBuffer(maxSamples);
try {
final response = await _isolateManagerBang.sendMessage(
LSLMessage(LSLMessageType.pullChunkBytes, {
'buffer': buf.addresses,
'channels': streamInfo.channelCount,
'timeout': timeout,
}),
timeoutSeconds: timeout + 30,
);
if (!response.success) {
throw LSLException('Error pulling binary chunk: ${response.error}');
}
return _binaryChunkFromBuffer(buf, response.result as int);
} finally {
buf.free();
}
}