pullSample method

LSLSamplePointer<T> pullSample(
  1. Pointer<T> buffer,
  2. lsl_inlet inlet,
  3. int channels,
  4. double timeout,
)

Allocates a sample buffer and calls the LSL pull function. @param buffer The buffer to store the sample. @param inlet The inlet to pull the sample from. @param channels The number of channels in the sample. @param timeout The timeout in seconds. @return LSLSamplePointer The sample pointer.

Implementation

LSLSamplePointer<T> pullSample(
  Pointer<T> buffer,
  lsl_inlet inlet,
  int channels,
  double timeout,
) {
  final Pointer<Int32> ec = allocate<Int32>();
  final double timestamp = _pullFn(inlet, buffer, channels, timeout, ec);
  final int errorCode = ec.value;
  if (LSLObj.error(errorCode)) {
    return LSLSamplePointer<T>(timestamp, errorCode, 0);
  }
  ec.free();
  return LSLSamplePointer<T>(timestamp, errorCode, buffer.address);
}