LSLInlet<T> class

A unified LSL inlet that supports both isolated and direct execution modes.

Execution Modes:

  • useIsolates: true` (default): Thread-safe, async-only operations
  • useIsolates: false: Direct FFI calls, supports both sync and async This will run in whichever isolate it is created in, and may perform blocking operations. ! You must ensure thread safety yourself when using this mode.

Sync Methods: Sync methods (ending in Sync) are only available when useIsolates: false. They provide maximum timing precision by eliminating async scheduling overhead.

// For thread safety (default)
final inlet = await LSL.createInlet<double>(streamInfo: info);
final sample = await inlet.pullSample();

// For timing precision
final inlet = await LSL.createInlet<double>(streamInfo: info, useIsolates: false);
final sample = inlet.pullSampleSync(); // Zero async overhead

Constructors

LSLInlet(LSLStreamInfo _streamInfo, {int maxBuffer = 360, int chunkSize = 0, bool recover = true, double createTimeout = LSL_FOREVER, Set<LSLTransportOptions> transportOptions = const {}, bool useIsolates = true})
Creates a new LSLInlet instance. Parameters:

Properties

chunkSize → int
Maximum chunk length in seconds. This is the the maximum number of complete samples that can be pulled in a single call to pullSampleChunked (not yet implemented). Default is 0, which means it will use the default chunk length of the corresponding outlet.
final
created → bool
Whether the object has been created.
no setterinherited
createTimeout → double
Timeout for creating the inlet in isolated mode. This is only used when useIsolates: true. Default is LSL_FOREVER, which means it will wait indefinitely.
final
destroyed → bool
Whether the object has been destroyed.
no setterinherited
hashCode → int
The hash code for this object.
no setteroverride
inlet → lsl_inlet
The underlying lsl_inlet pointer.
no setter
maxBuffer → int
Maximum buffer size in seconds. This is how many seconds of samples are stored in the inlet's buffer. Default is 360 seconds (6 minutes).
final
recover → bool
Whether to recover from lost samples. Default is true, which means it will try to recover lost samples.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
streamInfo → LSLStreamInfo
The LSLStreamInfo stream information for this outlet.
no setter
transportOptions → Set<LSLTransportOptions>
Transport flags applied at creation via lsl_create_inlet_ex.
final
useIsolates → bool
Whether the inlet is created using isolates or direct FFI calls.
no setter

Methods

addAlloc(Pointer<NativeType> arg) → void
Adds a pointer to the list of allocated pointers.
inherited
addAllocList(List<Pointer<NativeType>> args) → void
Adds a list of pointers to the list of allocated pointers.
inherited
create() → Future<LSLInlet<T>>
Creates the inlet based on the execution mode This method must be called before using the inlet. It initializes the inlet and prepares it for pulling samples. Execution:
createFromPointer(lsl_inlet pointer, {bool takeOwnership = false}) → Future<LSLInlet<T>>
Creates an inlet from an existing lsl_inlet pointer. Parameters:
destroy() → Future<void>
Destroys the inlet and cleans up resources. You can no longer use the inlet after calling this method.
flush() → Future<int>
Flushes the inlet's buffer. Execution:
flushSync() → int
freeArgs() → void
Frees all allocated pointers.
inherited
getFullInfo({required double timeout}) → Future<LSLStreamInfoWithMetadata>
Gets the full stream info with metadata from this inlet. Parameters:
getFullInfoSync({required double timeout}) → LSLStreamInfoWithMetadata
Synchronously gets the full stream info with metadata from this inlet. Direct mode only - throws LSLException if useIsolates: true. This provides maximum timing precision by eliminating all async overhead. Example:
getTimeCorrection({double timeout = 5.0}) → Future<double>
Gets the time correction for the inlet. Parameters:
getTimeCorrectionEx({double timeout = 5.0}) → Future<LSLTimeCorrection>
Gets the extended time correction for the inlet: the clock offset, the LSLTimeCorrection.remoteTime it was measured against, and the LSLTimeCorrection.uncertainty (full round-trip time) that bounds it.
getTimeCorrectionExSync({double timeout = 5.0}) → LSLTimeCorrection
Synchronously gets the extended time correction for the inlet. Direct mode only - throws LSLException if useIsolates: true. See getTimeCorrectionEx.
getTimeCorrectionSync({double timeout = 5.0}) → double
Synchronously gets the time correction for the inlet. Direct mode only - throws LSLException if useIsolates: true. This provides maximum timing precision by eliminating all async overhead. Example:
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pullChunk({int maxSamples = 512, double timeout = 0.0}) → Future<LSLChunk<T>>
Pulls a chunk of buffered samples from the inlet.
pullChunkBytes({int maxSamples = 512, double timeout = 0.0}) → Future<LSLChunk<Uint8List>>
Pulls a chunk of a string stream as raw bytes.
pullChunkBytesSync({int maxSamples = 512, double timeout = 0.0}) → LSLChunk<Uint8List>
Synchronously pulls a chunk of a string stream as raw bytes.
pullChunkPointerSync({int maxSamples = 512, double timeout = 0.0}) → LSLChunkPointer
Pulls a chunk and returns raw pointers into the reusable buffer (zero-copy escape hatch).
pullChunkSync({int maxSamples = 512, double timeout = 0.0}) → LSLChunk<T>
Synchronously pulls a chunk of buffered samples.
pullChunkTyped({int maxSamples = 512, double timeout = 0.0}) → Future<LSLChunkTyped>
Pulls a chunk as flat TypedData (fast path).
pullChunkTypedSync({int maxSamples = 512, double timeout = 0.0}) → LSLChunkTyped
Synchronously pulls a chunk as flat TypedData.
pullSample({double timeout = 0.0}) → Future<LSLSample<T>>
Pulls a sample from the inlet.
pullSampleBytes({double timeout = 0.0}) → Future<LSLSample<Uint8List>>
Pulls one sample of a string stream as raw bytes.
pullSampleBytesSync({double timeout = 0.0}) → LSLSample<Uint8List>
Synchronously pulls one sample of a string stream as raw bytes.
pullSamplePointerSync({double timeout = 0.0}) → LSLSamplePointer<NativeType>
Pull a sample but return the pointer instead of copying data. This may be used for advanced use cases where you want to avoid copying data out of the buffer. Parameters:
pullSampleSync({double timeout = 0.0}) → LSLSample<T>
Synchronously pulls a sample from the inlet.
requireDirect<R>(R operation()) → R
Helper to enforce direct-only operations
inherited
samplesAvailable() → Future<int>
Checks how many samples are available in the inlet's buffer. Execution:
samplesAvailableSync() → int
Synchronously checks how many samples are available in the inlet's buffer. Direct mode only - throws LSLException if useIsolates: true. This provides maximum timing precision by eliminating all async overhead. Returns: Number of samples available in the inlet's buffer, if the OS supports it, otherwise, 1 if there is at least one sample available, or 0 if no samples are available.
setPostProcessing(Set<LSLProcessingOptions> options) → Future<void>
Enables automatic post-processing of incoming time stamps.
setPostProcessingSync(Set<LSLProcessingOptions> options) → void
Synchronously enables automatic post-processing of incoming time stamps. Direct mode only - throws LSLException if useIsolates: true. See setPostProcessing.
setSmoothingHalftime(double halftime) → Future<void>
Overrides the half-time (forget factor) of the time-stamp smoothing used by LSLProcessingOptions.dejitter.
setSmoothingHalftimeSync(double halftime) → void
Synchronously overrides the time-stamp smoothing half-time. Direct mode only - throws LSLException if useIsolates: true. See setSmoothingHalftime.
setupPullBuffer() → void
Sets up the pull buffer for sample data. This allocates memory based on the channel count and initializes the pull function. Throws: LSLException if buffer allocation fails.
toString() → String
A string representation of this object.
inherited
wasClockReset() → Future<bool>
Whether the source machine's clock may have been reset since the last call to this method.
wasClockResetSync() → bool
Synchronously checks whether the source clock was reset. Direct mode only - throws LSLException if useIsolates: true. See wasClockReset.

Operators

operator ==(Object other) → bool
The equality operator.
override