pullSampleBytes method

Future<LSLSample<Uint8List>> pullSampleBytes({
  1. double timeout = 0.0,
})

Pulls one sample of a string stream as raw bytes.

The binary counterpart of pullSample (via lsl_pull_sample_buf): values keep any 0x00 bytes, which pullSample would truncate at. Works for string-format streams only.

Returns: An LSLSample of Uint8List; empty (timestamp 0) if no sample arrived within timeout.

Implementation

Future<LSLSample<Uint8List>> pullSampleBytes({double timeout = 0.0}) async {
  if (!_useIsolates) {
    return _pullSampleBytesDirect(timeout);
  }
  final buf = _binarySampleBuffer();
  try {
    final response = await _isolateManagerBang.sendMessage(
      LSLMessage(LSLMessageType.pullSampleBytes, {
        'buffer': buf.addresses,
        'timeout': timeout,
      }),
      timeoutSeconds: timeout + 30,
    );
    if (!response.success) {
      throw LSLException('Error pulling binary sample: ${response.error}');
    }
    return _binarySampleFromBuffer(buf, response.result as double);
  } finally {
    buf.free();
  }
}