Skip to content
Snippets Groups Projects
Commit c9b4a82a authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix localbuilder concurrency bug

parent bcac9229
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28187 failed
......@@ -104,7 +104,7 @@ CUDARender::CUDARender(nlohmann::json &config) : ftl::render::FSRenderer(config)
}
CUDARender::~CUDARender() {
delete colouriser_;
}
void CUDARender::_renderChannel(ftl::rgbd::Frame &output, ftl::codecs::Channel in, const Eigen::Matrix4d &t, cudaStream_t stream) {
......
......@@ -82,6 +82,7 @@ class LocalBuilder : public BaseBuilder {
private:
std::shared_ptr<ftl::data::FrameSet> frameset_;
SHARED_MUTEX mtx_;
std::shared_ptr<ftl::data::FrameSet> _allocate(int64_t timestamp);
};
......
......@@ -52,6 +52,7 @@ LocalBuilder::~LocalBuilder() {
}
LockedFrameSet LocalBuilder::get(int64_t timestamp, size_t ix) {
SHARED_LOCK(mtx_, lk);
if (!frameset_) {
frameset_ = _allocate(timestamp);
}
......@@ -61,6 +62,7 @@ LockedFrameSet LocalBuilder::get(int64_t timestamp, size_t ix) {
}
LockedFrameSet LocalBuilder::get(int64_t timestamp) {
SHARED_LOCK(mtx_, lk);
if (!frameset_) {
frameset_ = _allocate(timestamp);
}
......@@ -75,14 +77,16 @@ void LocalBuilder::setFrameCount(size_t size) {
}
std::shared_ptr<ftl::data::FrameSet> LocalBuilder::getNextFrameSet(int64_t ts) {
UNIQUE_LOCK(mtx_, lk);
if (!frameset_) {
frameset_ = _allocate(ts);
}
auto fs = frameset_;
frameset_ = _allocate(ts+1);
lk.unlock();
// Must lock to ensure no updates can happen here
UNIQUE_LOCK(fs->smtx, lk);
frameset_ = _allocate(ts+1);
UNIQUE_LOCK(fs->smtx, lk2);
fs->changeTimestamp(ts);
fs->store();
//for (auto &f : fs->frames) {
......
......@@ -84,7 +84,8 @@ Feed::Feed(nlohmann::json &config, ftl::net::Universe*net) :
restore(ftl::Configurable::getID(), {
"recent_files",
"known_hosts",
"auto_host_connect"
"auto_host_connect",
"auto_host_sources"
});
pool_ = std::make_unique<ftl::data::Pool>(3,5);
......
......@@ -48,6 +48,7 @@ Source::Source(nlohmann::json &config, ftl::stream::Feed *feed)
Source::~Source() {
if (filter_) filter_->remove();
delete intrinsics_;
}
bool Source::capture(int64_t ts) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment