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.new(LSLStreamInfo _streamInfo, {int maxBuffer = 360, int chunkSize = 0, bool recover = true, double createTimeout = LSL_FOREVER, 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 setterinherited
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
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:
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:
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
pullSample({double timeout = 0.0}) Future<LSLSample<T>>
Pulls a sample from the inlet.
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.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited