diff --git a/src/dab/database/dab_database_updater.cpp b/src/dab/database/dab_database_updater.cpp index 289fac6..0ba6e63 100644 --- a/src/dab/database/dab_database_updater.cpp +++ b/src/dab/database/dab_database_updater.cpp @@ -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() { diff --git a/src/dab/database/dab_database_updater.h b/src/dab/database/dab_database_updater.h index bf7a5da..516826d 100644 --- a/src/dab/database/dab_database_updater.h +++ b/src/dab/database/dab_database_updater.h @@ -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; @@ -84,13 +85,14 @@ class DatabaseEntityUpdater return UpdateResult::SUCCESS; } template - 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;