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

Method init_streamer

src/board_controller/multicast_streamer.cpp:41–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41int MultiCastStreamer::init_streamer ()
42{
43 if ((is_streaming) || (server != NULL) || (db != NULL))
44 {
45 Board::board_logger->error ("multicast streamer is running");
46 return (int)BrainFlowExitCodes::GENERAL_ERROR;
47 }
48
49 server = new MultiCastServer (ip, port);
50 int res = server->init ();
51 if (res != (int)MultiCastReturnCodes::STATUS_OK)
52 {
53 delete server;
54 server = NULL;
55 Board::board_logger->error ("failed to init server multicast socket {}", res);
56 return (int)BrainFlowExitCodes::GENERAL_ERROR;
57 }
58
59 db = new DataBuffer (len, 1000);
60 if (!db->is_ready ())
61 {
62 Board::board_logger->error ("unable to prepare buffer for multicast");
63 delete db;
64 db = NULL;
65 delete server;
66 server = NULL;
67 return (int)BrainFlowExitCodes::INVALID_BUFFER_SIZE_ERROR;
68 }
69
70 is_streaming = true;
71 streaming_thread = std::thread ([this] { this->thread_worker (); });
72 return (int)BrainFlowExitCodes::STATUS_OK;
73}
74
75void MultiCastStreamer::stream_data (double *data)
76{

Callers

nothing calls this directly

Calls 3

thread_workerMethod · 0.95
is_readyMethod · 0.80
initMethod · 0.45

Tested by

no test coverage detected