MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / start_streaming_prepared

Method start_streaming_prepared

src/board_controller/openbci/ganglion.cpp:179–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179int Ganglion::start_streaming_prepared ()
180{
181 int res = call_start ();
182 if (res != (int)BrainFlowExitCodes::STATUS_OK)
183 {
184 return res;
185 }
186
187 keep_alive = true;
188 streaming_thread = std::thread ([this] { read_thread (); });
189
190 // wait for data to ensure that everything is okay
191 std::unique_lock<std::mutex> lk (m);
192 auto sec = std::chrono::seconds (1);
193 if (cv.wait_for (lk, params.timeout * sec,
194 [this] { return state != (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR; }))
195 {
196 is_streaming = true;
197 return state;
198 }
199 else
200 {
201 safe_logger (
202 spdlog::level::err, "no data received in {} sec, stopping thread", params.timeout);
203 is_streaming = true;
204 stop_stream ();
205 return (int)BrainFlowExitCodes::SYNC_TIMEOUT_ERROR;
206 }
207}
208
209int Ganglion::stop_stream ()
210{

Callers

nothing calls this directly

Calls 1

stop_streamFunction · 0.50

Tested by

no test coverage detected