Skip to content

Commit

Permalink
Let service component global id be incoherent
Browse files Browse the repository at this point in the history
  • Loading branch information
williamyang98 committed Feb 18, 2024
1 parent 4c2fccc commit 07757ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/dab/database/dab_database_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ UpdateResult ServiceComponentUpdater::SetSubchannel(const subchannel_id_t subcha
}

UpdateResult ServiceComponentUpdater::SetGlobalID(const service_component_global_id_t global_id) {
return UpdateField(GetData().global_id, global_id, SERVICE_COMPONENT_FLAG_GLOBAL_ID);
// In some transmitters they keep changing this for some reason?
return UpdateField(GetData().global_id, global_id, SERVICE_COMPONENT_FLAG_GLOBAL_ID, true);
}

uint32_t ServiceComponentUpdater::GetServiceReference() {
Expand Down
14 changes: 8 additions & 6 deletions src/dab/database/dab_database_updater.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ class DatabaseEntityUpdater
m_total_updates++;
m_stats.nb_updates++;
}
UpdateResult UpdateField(std::string& dst, std::string_view src, T dirty_flag) {
UpdateResult UpdateField(std::string& dst, std::string_view src, T dirty_flag, bool ignore_conflict=false) {
if (m_dirty_field & dirty_flag) {
if (src.compare(dst) != 0) {
if (src.compare(dst) == 0) {
return UpdateResult::NO_CHANGE;
} else if (!ignore_conflict) {
OnConflict();
return UpdateResult::CONFLICT;
}
return UpdateResult::NO_CHANGE;
}
m_dirty_field |= dirty_flag;
dst = src;
Expand All @@ -84,13 +85,14 @@ class DatabaseEntityUpdater
return UpdateResult::SUCCESS;
}
template <typename U>
UpdateResult UpdateField(U& dst, U src, T dirty_flag) {
UpdateResult UpdateField(U& dst, U src, T dirty_flag, bool ignore_conflict=false) {
if (m_dirty_field & dirty_flag) {
if (dst != src) {
if (dst == src) {
return UpdateResult::NO_CHANGE;
} else if (!ignore_conflict) {
OnConflict();
return UpdateResult::CONFLICT;
}
return UpdateResult::NO_CHANGE;
}
m_dirty_field |= dirty_flag;
dst = src;
Expand Down

0 comments on commit 07757ad

Please sign in to comment.