From 64e6ee1c0abc291a174ee9011792f3294b3401ff Mon Sep 17 00:00:00 2001 From: Kevin Matz Date: Mon, 12 Dec 2022 11:32:26 -0500 Subject: [PATCH] add refresh function to consolidate maintenance tasks --- protocol/esta/sacn/receiver.cpp | 2 +- protocol/esta/sacn/universearbitrator.cpp | 13 +++++++++++-- protocol/esta/sacn/universearbitrator.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/protocol/esta/sacn/receiver.cpp b/protocol/esta/sacn/receiver.cpp index 047f3bf..591072e 100644 --- a/protocol/esta/sacn/receiver.cpp +++ b/protocol/esta/sacn/receiver.cpp @@ -323,7 +323,7 @@ void Receiver::dataFrameHandler(ACN::PDU::Message frame) universe->DmpReceiver(block); // do ArbitratingUniverse maintence tasks - universes_.at(metadata->universe)->rxRate(); + universes_.at(metadata->universe)->refresh(); } diff --git a/protocol/esta/sacn/universearbitrator.cpp b/protocol/esta/sacn/universearbitrator.cpp index 5cea570..8c94085 100644 --- a/protocol/esta/sacn/universearbitrator.cpp +++ b/protocol/esta/sacn/universearbitrator.cpp @@ -41,6 +41,16 @@ UniverseArbitrator::UniverseArbitrator() } +/** + * @brief UniverseArbitrator::refresh + */ +void UniverseArbitrator::refresh() +{ + purge_stale_sources_(); + find_dominant_(); +} + + /** * @brief UniverseArbitrator::setHoldLastLook * @param state @@ -268,8 +278,7 @@ uint8_t UniverseArbitrator::slot(const uint16_t address) const */ double UniverseArbitrator::rxRate() { - purge_stale_sources_(); - find_dominant_(); + refresh(); auto universe = m_dominant.lock(); if (!universe) return 0.0; diff --git a/protocol/esta/sacn/universearbitrator.h b/protocol/esta/sacn/universearbitrator.h index 534bb04..b9f1faa 100644 --- a/protocol/esta/sacn/universearbitrator.h +++ b/protocol/esta/sacn/universearbitrator.h @@ -58,6 +58,7 @@ public: explicit UniverseArbitrator(); uint16_t expectedUniverse; ///< Expected universe number + void refresh(); // Source universes: void deleteSourceUniverse(const DATA::data_header&);