v2.0.0
Loading...
Searching...
No Matches
lsl_stream_outlet.cpp File Reference

Implements the TCP-server / UDP-announcer worker that publishes pushed samples to every connected LSL inlet. More...

#include "lsl_stream_outlet.h"
#include <QTcpServer>
#include <QTcpSocket>
#include <QUdpSocket>
#include <QHostAddress>
#include <QDebug>
#include <thread>
#include <mutex>
#include <atomic>
#include <cstring>
#include <queue>
#include <chrono>
Include dependency graph for lsl_stream_outlet.cpp:

Go to the source code of this file.

Classes

class  LSLLIB::StreamOutletPrivate

Detailed Description

Implements the TCP-server / UDP-announcer worker that publishes pushed samples to every connected LSL inlet.

SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2026 MNE-CPP Authors

Author
Christoph Dinh chris.nosp@m.toph.nosp@m..dinh.nosp@m.@mne.nosp@m.-cpp..nosp@m.org
Since
2.0.0
Date
March 2026

The PIMPL class StreamOutletPrivate spawns a dedicated std::thread that owns a QTcpServer for accepting inlet connections, a QUdpSocket that emits the stream's serialised LSLLIB::stream_info to the LSL discovery multicast group 239.255.172.215:16571 every BROADCAST_INTERVAL_MS milliseconds, and a mutex-protected queue that buffers samples pushed from the producing thread.

On every loop iteration the worker drains the queue, packs each sample as a contiguous channel_count * sizeof(float) byte block, and writes the result to every currently connected inlet socket; the multicast advertisement keeps firing on its own cadence so that newly started LSLLIB::resolve_streams calls discover the outlet within at most one broadcast interval. The destructor signals the worker to stop, joins it, closes all sockets and tears down the server, guaranteeing that no Qt object outlives its owning thread.

Definition in file lsl_stream_outlet.cpp.