@@ -140,6 +140,12 @@ class DataStreamConfig extends NetworkStreamConfig {
140140 /// Defines who should participate in this data stream
141141 final StreamParticipationMode participationMode;
142142
143+ /// Whether precise polling is enabled for this data stream.
144+ /// i.e. with the LSL transport, it will use busy-waiting to achieve lower
145+ /// latency at the cost of higher CPU usage.
146+ /// Defaults to true.
147+ final bool precisePolling;
148+
143149 /// Transport-specific configuration for the data stream.
144150 @override
145151 TransportStreamConfig ? get transportConfig => _transportConfig;
@@ -153,13 +159,15 @@ class DataStreamConfig extends NetworkStreamConfig {
153159 required super .sampleRate,
154160 required super .dataType,
155161 this .participationMode = StreamParticipationMode .sendAllReceiveCoordinator,
162+ this .precisePolling = true ,
156163 TransportStreamConfig ? transportConfig,
157164 }) : _transportConfig = transportConfig;
158165
159166 @override
160167 Map <String , dynamic > toMap () {
161168 final map = super .toMap ();
162169 map['participationMode' ] = participationMode.toString ();
170+ map['precisePolling' ] = precisePolling;
163171
164172 return map;
165173 }
@@ -180,6 +188,7 @@ class DataStreamConfig extends NetworkStreamConfig {
180188 other.sampleRate == sampleRate &&
181189 other.dataType == dataType &&
182190 other.participationMode == participationMode &&
191+ other.precisePolling == precisePolling &&
183192 other.transportConfig == transportConfig;
184193 }
185194
@@ -190,6 +199,7 @@ class DataStreamConfig extends NetworkStreamConfig {
190199 sampleRate,
191200 dataType,
192201 participationMode,
202+ precisePolling,
193203 transportConfig,
194204 );
195205}
@@ -226,6 +236,7 @@ class DataStreamConfigFactory implements IConfigFactory<DataStreamConfig> {
226236 orElse: () =>
227237 StreamParticipationMode .sendParticipantsReceiveCoordinator,
228238 ),
239+ precisePolling: map['precisePolling' ] ?? true ,
229240 transportConfig: null , // Needs proper handling
230241 );
231242 }
0 commit comments