Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 99 - Metadata always reported as changed #111

Merged
merged 6 commits into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ void DirectSpeakersMetadataSender::sendMetadata() {
return;
}
auto msg = getMessage();
data_.set_changed(false);
socket_.asyncSend(
msg, [this](std::error_code ec, const nng::Message& ignored) {
if (!ec) {
std::lock_guard<std::mutex> lock(timeoutMutex_);
lastSendTimestamp_ = std::chrono::system_clock::now();
} else {
data_.set_changed(true);
EAR_LOGGER_WARN(logger_, "Metadata sending failed: {}", ec.message());
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ void ObjectMetadataSender::sendMetadata() {
return;
}
auto msg = getMessage();
data_.set_changed(false);
socket_.asyncSend(
msg, [this](std::error_code ec, const nng::Message& ignored) {
if (!ec) {
std::lock_guard<std::mutex> lock(timeoutMutex_);
lastSendTimestamp_ = std::chrono::system_clock::now();
} else {
data_.set_changed(true);
EAR_LOGGER_WARN(logger_, "Metadata sending failed: {}", ec.message());
}
});
Expand Down
7 changes: 5 additions & 2 deletions ear-production-suite-plugins/lib/src/scene_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ void SceneBackend::triggerMetadataSend() {
}
});
std::lock_guard<std::mutex> lock(storeMutex_);
for (auto item : itemStore_) {
item.second.set_changed(false);
for (auto& item : itemStore_) {
if(item.second.changed()) {
item.second.set_changed(false);
rebuildSceneStore_ = true;
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions ear-production-suite-plugins/plugins/scene/src/item_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class ItemView : public Component {
repaint();
}

void setMetadata(ear::plugin::proto::InputItemMetadata const& metadata) {
data_.metadata = metadata;
repaint();
}

void setSelected(bool selected) {
data_.selected = selected;
repaint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ void JuceSceneFrontendConnector::reloadItemListCache() {
});
if (it == container->directSpeakersItems.end()) {
auto view = std::make_shared<ItemView>();
view->setData({item, false});
view->setMetadata(item);
container->directSpeakersItems.push_back(view);
container->directSpeakersList->addItem(view.get());
} else {
(*it)->setData({item, false});
(*it)->setMetadata(item);
}
} else if (item.has_obj_metadata()) {
auto it = std::find_if(
Expand All @@ -192,11 +192,11 @@ void JuceSceneFrontendConnector::reloadItemListCache() {
});
if (it == container->objectsItems.end()) {
auto view = std::make_shared<ItemView>();
view->setData({item, false});
view->setMetadata(item);
container->objectsItems.push_back(view);
container->objectsList->addItem(view.get());
} else {
(*it)->setData({item, false});
(*it)->setMetadata(item);
}
}
}
Expand Down Expand Up @@ -301,10 +301,10 @@ void JuceSceneFrontendConnector::updateItemView(communication::ConnectionId id,
container->directSpeakersItems.end(),
[id](auto entry) { return id == entry->getId(); });
if (it != container->directSpeakersItems.end()) {
(*it)->setData({item, false});
(*it)->setMetadata(item);
} else {
auto view = std::make_shared<ItemView>();
view->setData({item, false});
view->setMetadata(item);
container->directSpeakersItems.push_back(view);
container->directSpeakersList->addItem(view.get());
}
Expand All @@ -313,10 +313,10 @@ void JuceSceneFrontendConnector::updateItemView(communication::ConnectionId id,
container->objectsItems.end(),
[id](auto entry) { return id == entry->getId(); });
if (it != container->objectsItems.end()) {
(*it)->setData({item, false});
(*it)->setMetadata(item);
} else {
auto view = std::make_shared<ItemView>();
view->setData({item, false});
view->setMetadata(item);
container->objectsItems.push_back(view);
container->objectsList->addItem(view.get());
}
Expand Down