createSample method

  1. @protected
LSLSample<D> createSample(
  1. Pointer<T> buffer,
  2. lsl_inlet inlet,
  3. int channels,
  4. double timeout,
)

Implementation

@protected
LSLSample<D> createSample(
  Pointer<T> buffer,
  lsl_inlet inlet,
  int channels,
  double timeout,
) {
  final Pointer<Int32> ec = allocate<Int32>();
  try {
    final double timestamp = _pullFn(inlet, buffer, channels, timeout, ec);
    final int errorCode = ec.value;
    if (LSLObj.error(errorCode) || timestamp <= 0) {
      return LSLSample<D>(IList(), timestamp, errorCode);
    }
    final IList<D> result = bufferToList(buffer, channels);
    return LSLSample<D>(result, timestamp, errorCode);
  } finally {
    ec.free();
    if (!buffer.isNullPointer) {
      buffer.free();
    }
  }
}