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

Add more locks to feed

parent e8948bae
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
Pipeline #28434 passed
......@@ -298,6 +298,7 @@ void Feed::select() {
std::vector<std::string> Feed::listSources() {
std::vector<std::string> sources;
SHARED_LOCK(mtx_, lk);
sources.reserve(fsid_lookup_.size());
for (auto& [uri, fsid] : fsid_lookup_) {
std::ignore = fsid;
......@@ -322,9 +323,11 @@ Feed::Filter* Feed::filter(const std::unordered_set<Channel> &channels) {
Feed::Filter* Feed::filter(const std::unordered_set<std::string> &sources, const std::unordered_set<Channel> &channels) {
std::unordered_set<uint32_t> fsids;
SHARED_LOCK(mtx_, lk);
for (const auto &src : sources) {
ftl::URI uri(src);
// FIXME: If this map is modified, this could crash here.
auto i = fsid_lookup_.find(uri.getBaseURI());
if (i != fsid_lookup_.end()) {
fsids.emplace(i->second);
......@@ -479,6 +482,7 @@ void Feed::updateNetSources() {
}
std::vector<std::string> Feed::availableNetworkSources() {
SHARED_LOCK(mtx_, lk);
return netcams_;
}
......@@ -523,6 +527,7 @@ bool Feed::sourceAvailable(const std::string &uri) {
bool Feed::sourceActive(const std::string &suri) {
ftl::URI uri(suri);
SHARED_LOCK(mtx_, lk);
return fsid_lookup_.count(uri.getBaseURI()) > 0;
}
......@@ -737,6 +742,7 @@ const std::unordered_set<Channel> Feed::availableChannels(ftl::data::FrameID id)
std::vector<ftl::data::FrameID> Feed::listFrames() {
std::vector<ftl::data::FrameID> result;
SHARED_LOCK(mtx_, lk);
result.reserve(fsid_lookup_.size());
for (const auto [k, fs] : latest_) {
for (unsigned i = 0; i < fs->frames.size(); i++) {
......@@ -747,6 +753,7 @@ std::vector<ftl::data::FrameID> Feed::listFrames() {
}
std::string Feed::getURI(uint32_t fsid) {
SHARED_LOCK(mtx_, lk);
for (const auto& [k, v] : fsid_lookup_) {
if (v == fsid) {
return k;
......@@ -771,6 +778,7 @@ std::string Feed::getSourceURI(ftl::data::FrameID id) {
}
std::vector<unsigned int> Feed::listFrameSets() {
SHARED_LOCK(mtx_, lk);
std::vector<unsigned int> result;
result.reserve(fsid_lookup_.size());
for (const auto [k, fs] : latest_) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment