createOutlet static method

Future<LSLOutlet> createOutlet({
  1. required LSLStreamInfo streamInfo,
  2. int chunkSize = 0,
  3. int maxBuffer = 360,
  4. Set<LSLTransportOptions> transportOptions = const {},
  5. bool useIsolates = true,
})

Creates a new outlet object.

chunkSize determines how to hand off samples to the buffer, 0 creates a chunk for each push.

maxBuffer determines the size of the buffer that stores incoming samples. NOTE: This is in seconds, if the stream has a sample rate, otherwise it is in 100s of samples (maxBuffer * 10^2). High values will use more memory, low values may lose samples, this should be set as close as possible to the rate of consumption. useIsolates determines whether to use isolates for thread safety. If true, the outlet will use isolates to ensure thread safety. Important: If you do not use isolates, you must ensure that you deal with the consequences of blocking operations which will block the main dart isolate.

transportOptions applies transport flags at creation time, see LSLOutlet.transportOptions. LSLTransportOptions.syncBlocking enables zero-copy blocking socket writes: every push blocks until the data has been handed to the OS for all connected consumers (lower CPU use for high-bandwidth streams, higher per-push latency; incompatible with string streams; push from only one thread at a time). The bufsize options change the unit of maxBuffer.

Implementation

static Future<LSLOutlet> createOutlet({
  required LSLStreamInfo streamInfo,
  int chunkSize = 0,
  int maxBuffer = 360,
  Set<LSLTransportOptions> transportOptions = const {},
  bool useIsolates = true,
}) async {
  final streamOutlet = LSLOutlet(
    streamInfo,
    chunkSize: chunkSize,
    maxBuffer: maxBuffer,
    transportOptions: transportOptions,
    useIsolates: useIsolates,
  );
  await streamOutlet.create();

  return streamOutlet;
}