From 0ad75d508adb30e3037154d82cd39f8574475aec Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Wed, 19 Aug 2020 21:08:02 +0300 Subject: [PATCH] Fix unwanted latency --- applications/vision/src/main.cpp | 9 +++------ components/operators/src/operator.cpp | 2 -- components/streams/src/feed.cpp | 8 +++++++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/applications/vision/src/main.cpp b/applications/vision/src/main.cpp index d8f4d58a5..b9f893300 100644 --- a/applications/vision/src/main.cpp +++ b/applications/vision/src/main.cpp @@ -197,10 +197,7 @@ static void run(ftl::Configurable *root) { "clipping" }); - std::atomic_flag busy; - busy.clear(); - - auto h = creator->onFrameSet([sender,outstream,&stats_count,&latency,&frames,&stats_time,pipeline,&busy,&encodable,&previous_encodable](const ftl::data::FrameSetPtr &fs) { + auto h = creator->onFrameSet([sender,outstream,&stats_count,&latency,&frames,&stats_time,pipeline,&encodable,&previous_encodable](const ftl::data::FrameSetPtr &fs) { // Decide what to encode here, based upon what remote users select const auto sel = outstream->selectedNoExcept(fs->frameset()); @@ -222,7 +219,7 @@ static void run(ftl::Configurable *root) { fs->set(ftl::data::FSFlag::AUTO_SEND); - bool did_pipe = pipeline->apply(*fs, *fs, [fs,&frames,&latency,&busy]() { + bool did_pipe = pipeline->apply(*fs, *fs, [fs,&frames,&latency]() { if (fs->hasAnyChanged(Channel::Depth)) fs->flush(Channel::Depth); ++frames; latency += float(ftl::timer::get_time() - fs->timestamp()); @@ -236,7 +233,7 @@ static void run(ftl::Configurable *root) { // Do some encoding (eg. colour) whilst pipeline runs - ftl::pool.push([fs,&stats_count,&latency,&frames,&stats_time,&busy](int id){ + ftl::pool.push([fs,&stats_count,&latency,&frames,&stats_time](int id){ if (fs->hasAnyChanged(Channel::Audio)) { fs->flush(ftl::codecs::Channel::Audio); } diff --git a/components/operators/src/operator.cpp b/components/operators/src/operator.cpp index f0e5c6771..4cc0f9059 100644 --- a/components/operators/src/operator.cpp +++ b/components/operators/src/operator.cpp @@ -83,7 +83,6 @@ bool Graph::apply(FrameSet &in, FrameSet &out, const std::function<void()> &cb) return false; } - callback_ = cb; valid_buffers_.clear(); for (auto &f : out.frames) { @@ -184,7 +183,6 @@ bool Graph::apply(Frame &in, Frame &out, const std::function<void()> &cb) { } valid_buffers_.clear(); - callback_ = cb; if (!out.hasOwn(Channel::Pipelines)) out.create<std::list<std::string>>(Channel::Pipelines); auto pls = out.set<std::list<std::string>>(Channel::Pipelines); diff --git a/components/streams/src/feed.cpp b/components/streams/src/feed.cpp index ba46586d5..54b35d200 100644 --- a/components/streams/src/feed.cpp +++ b/components/streams/src/feed.cpp @@ -184,7 +184,9 @@ Feed::Feed(nlohmann::json &config, ftl::net::Universe*net) : lk.unlock(); - if (pipeline) pipeline->apply(*fs, *fs, [this,fs]() { + bool did_pipe = false; + + if (pipeline) did_pipe = pipeline->apply(*fs, *fs, [this,fs]() { SHARED_LOCK(mtx_, lk); std::atomic_store(&latest_.at(fs->frameset()), fs); @@ -222,6 +224,10 @@ Feed::Feed(nlohmann::json &config, ftl::net::Universe*net) : //lk.lock(); + if (!did_pipe) { + LOG(WARNING) << "GUI Pipeline dropped"; + } + return true; }); -- GitLab