| 177 | } |
| 178 | |
| 179 | int 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 | |
| 209 | int Ganglion::stop_stream () |
| 210 | { |
nothing calls this directly
no test coverage detected