LSLOutlet class

A unified LSL outlet 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 outlet = await LSL.createOutlet(streamInfo: info);
await outlet.pushSample([1.0, 2.0]);

// For timing precision
final outlet = await LSL.createOutlet(streamInfo: info, useIsolates: false);
outlet.pushSampleSync([1.0, 2.0]); // Zero async overhead

Constructors

LSLOutlet(LSLStreamInfo streamInfo, {int chunkSize = 0, int maxBuffer = 360, Set<LSLTransportOptions> transportOptions = const {}, bool useIsolates = true})
Creates a new LSLOutlet instance. Parameters:

Properties

chunkSize → int
Chunk size in samples for transmission. 0 creates a chunk for each push operation.
final
created → bool
Whether the object has been created.
no setterinherited
destroyed → bool
Whether the object has been destroyed.
no setterinherited
hashCode → int
The hash code for this object.
no setteroverride
maxBuffer → int
Maximum buffer size in seconds. This is how many seconds of samples are stored in the outlet's buffer. Default is 360 seconds (6 minutes). The unit changes when transportOptions contains LSLTransportOptions.bufsizeInSamples (samples) or LSLTransportOptions.bufsizeInThousandths (value * 0.001).
final
nativePush → LSLPushSample<NativeType>
no setter
outlet → lsl_outlet
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
streamInfo → LSLStreamInfo
The LSLStreamInfo stream information for this outlet.
final
transportOptions → Set<LSLTransportOptions>
Transport flags applied at creation via lsl_create_outlet_ex.
final
useIsolates → bool
Whether the outlet 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<LSLOutlet>
Creates the outlet based on the execution mode This method must be called before using the outlet. It initializes the outlet and prepares it for pushing samples. Execution:
createFromPointer(lsl_outlet pointer) → Future<LSLOutlet>
Creates an outlet from an existing lsl_outlet pointer. Parameters:
dataToBufferPointer(Iterable data) → Pointer<NativeType>
Writes data into the outlet's push buffer and returns the pointer.
destroy() → Future<void>
Destroys the outlet and cleans up resources. You can no longer use the outlet after calling this method.
freeArgs() → void
Frees all allocated pointers.
inherited
getInfo() → Future<LSLStreamInfoWithMetadata>
Gets a fresh copy of the stream info the outlet is serving, as liblsl sees it (including createdAt, hostname, sessionId and the full description).
getInfoSync() → LSLStreamInfoWithMetadata
Synchronously gets a copy of the outlet's stream info.
hasConsumers() → Future<bool>
Checks if consumers are currently connected to the outlet. Execution:
hasConsumersSync() → bool
Synchronously checks if consumers are currently connected to the outlet. Direct mode only - throws LSLException if useIsolates: true. Returns: true if consumers are connected, false otherwise.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pushChunk(List<List> samples, {double? timestamp, List<double>? timestamps, bool? pushthrough}) → Future<int>
Pushes a chunk of samples to the outlet.
pushChunkBytes(List<List<Uint8List>> samples, {double? timestamp, List<double>? timestamps, bool? pushthrough}) → Future<int>
Pushes a chunk of binary-string samples (string-format streams only).
pushChunkBytesSync(List<List<Uint8List>> samples, {double? timestamp, List<double>? timestamps, bool? pushthrough}) → int
Synchronously pushes a chunk of binary-string samples.
pushChunkSync(List<List> samples, {double? timestamp, List<double>? timestamps, bool? pushthrough}) → int
Synchronously pushes a chunk of samples to the outlet.
pushChunkTyped(TypedData data, {double? timestamp, Float64List? timestamps, bool? pushthrough}) → Future<int>
Pushes a chunk from a flat TypedData buffer (fast path).
pushChunkTypedSync(TypedData data, {double? timestamp, Float64List? timestamps, bool? pushthrough}) → int
Synchronously pushes a chunk from a flat TypedData buffer.
pushSample(Iterable data, {double? timestamp, bool? pushthrough}) → Future<int>
Pushes a sample to the outlet.
pushSampleBytes(List<Uint8List> data, {double? timestamp, bool? pushthrough}) → Future<int>
Pushes one sample of binary strings (string-format streams only).
pushSampleBytesSync(List<Uint8List> data, {double? timestamp, bool? pushthrough}) → int
Synchronously pushes one sample of binary strings.
pushSamplePointerSync(Pointer<NativeType> pointer, {double? timestamp, bool? pushthrough}) → int
Pushes a sample already written to pointer (see dataToBufferPointer). See pushSample for timestamp and pushthrough semantics.
pushSampleSync(Iterable data, {double? timestamp, bool? pushthrough}) → int
Synchronously pushes a sample to the outlet.
requireDirect<R>(R operation()) → R
Helper to enforce direct-only operations
inherited
toString() → String
A string representation of this object.
override
waitForConsumer({double timeout = 60.0}) → Future<bool>
Waits for a consumer (e.g. LabRecorder, another inlet) to connect to the outlet.
waitForConsumerSync({double timeout = 60.0}) → bool
Synchronously waits for a consumer to connect to the outlet.

Operators

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

Static Methods

validateTransportOptions(Set<LSLTransportOptions> options, LSLStreamInfo streamInfo) → void
Validates a transport-option set against a stream's channel format.