From 4b6b34836db8aaf4b25bb3889f88732a57a05765 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 27 May 2015 10:30:45 -0700 Subject: [PATCH] repair anomalies in timing table --- libraries/networking/src/NodeList.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index f9189e47d7..113ec4f155 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -677,8 +677,21 @@ void NodeList::flagTimeForConnectionStep(NodeList::ConnectionStep connectionStep _lastConnectionTimes.clear(); } - // we only add a timestamp on the first call for each NodeList::ConnectionStep if (!_lastConnectionTimes.contains(connectionStep)) { + // if there is no time for existing step add a timestamp on the first call for each NodeList::ConnectionStep _lastConnectionTimes[connectionStep] = timestamp; + } else { + // if the existing time for this step is before the nearest sibling before then replace it + // this handles the case where audio comes in after an address lookup after the previous times have been cleared + quint64 currentTime = _lastConnectionTimes[connectionStep]; + + // go down the sibling steps and check if the registered time is actually before the sibling + for (int i = ((int) connectionStep) - 1; i >= 0; i--) { + NodeList::ConnectionStep thisStep = static_cast(i); + if (_lastConnectionTimes.contains(thisStep) && _lastConnectionTimes[thisStep] >= currentTime) { + _lastConnectionTimes[connectionStep] = timestamp; + break; + } + } } }