LSLOutlet class
A unified LSL outlet that supports both isolated and direct execution modes.
Execution Modes:
useIsolates: true
(default): Thread-safe, async-only operationsuseIsolates: 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.new(LSLStreamInfo streamInfo, {int chunkSize = 0, int maxBuffer = 360, 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 setterinherited
- 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).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- streamInfo → LSLStreamInfo
-
The LSLStreamInfo stream information for this outlet.
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< args) → voidNativeType> > -
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:
-
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
-
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
-
pushSample(
List data) → Future< int> - Pushes a sample to the outlet.
-
pushSampleSync(
List data) → 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.
inherited