diff --git a/components/rgbd-sources/src/net.cpp b/components/rgbd-sources/src/net.cpp index 2e89c8617125d9fd7cf0bbf21e25ed5961dd6acd..b0f6b1a5dbeb942897b4249c20c45a680f9355f5 100644 --- a/components/rgbd-sources/src/net.cpp +++ b/components/rgbd-sources/src/net.cpp @@ -64,15 +64,11 @@ NetSource::~NetSource() { void NetSource::_recv(const vector<unsigned char> &jpg, const vector<unsigned char> &d) { cv::Mat tmp_rgb, tmp_depth; + // Decode in temporary buffers to prevent long locks cv::imdecode(jpg, cv::IMREAD_COLOR, &tmp_rgb); - //Mat(rgb_.size(), CV_16UC1); cv::imdecode(d, cv::IMREAD_UNCHANGED, &tmp_depth); - auto start = std::chrono::high_resolution_clock::now(); unique_lock<shared_mutex> lk(host_->mutex()); - std::chrono::duration<double> elapsed = - std::chrono::high_resolution_clock::now() - start; - LOG(INFO) << "ELAPSED LOCK: " << elapsed.count(); rgb_ = tmp_rgb; tmp_depth.convertTo(depth_, CV_32FC1, 1.0f/(16.0f*100.0f)); N_--; @@ -135,6 +131,7 @@ void NetSource::_updateURI() { } bool NetSource::grab() { + // Send one frame before end to prevent unwanted pause if (N_ <= 1) { N_ = 10; if (!host_->getNet()->send(peer_, "get_stream", *host_->get<string>("uri"), 10, 0, host_->getNet()->id(), *host_->get<string>("uri"))) { diff --git a/components/rgbd-sources/src/streamer.cpp b/components/rgbd-sources/src/streamer.cpp index ef0fdaae60e4783f35b0f828bc5338d58946f9e5..d5d2989fe1ca76ec0d016dff4e96ebfbe0692bf8 100644 --- a/components/rgbd-sources/src/streamer.cpp +++ b/components/rgbd-sources/src/streamer.cpp @@ -112,7 +112,7 @@ void Streamer::_addClient(const string &source, int N, int rate, const ftl::UUID if (rate < 0 || rate >= 10) return; if (N < 0 || N > ftl::rgbd::kMaxFrames) return; - LOG(INFO) << "Adding Stream Peer: " << peer.to_string(); + DLOG(INFO) << "Adding Stream Peer: " << peer.to_string(); StreamSource *s = sources_[source]; for (int i=0; i<s->clients[rate].size(); i++) { @@ -130,7 +130,6 @@ void Streamer::_addClient(const string &source, int N, int rate, const ftl::UUID c.txcount = 0; c.txmax = N; - //unique_lock<shared_mutex> ulk(s->mutex); s->clients[rate].push_back(c); }