| 296 | } |
| 297 | |
| 298 | void Controller::prepareCorrectionIndices() { |
| 299 | correction_on_total_.clear(); |
| 300 | for (size_t lr = 0; lr < 5; ++lr) { |
| 301 | correction_on_indices_[lr].clear(); |
| 302 | for (const size_t& i : not_off_indices_[lr]) { |
| 303 | if (c_filter_status_[i] == FilterStatus::kOn && !c_dynamic_on_[i]) { |
| 304 | correction_on_total_.emplace_back(i); |
| 305 | correction_on_indices_[lr].emplace_back(i); |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | if (correction_on_indices_[3].empty() && correction_on_indices_[4].empty()) { |
| 310 | for (const size_t& i : correction_on_indices_[0]) { |
| 311 | correction_on_indices_[1].emplace_back(i); |
| 312 | correction_on_indices_[2].emplace_back(i); |
| 313 | } |
| 314 | } else { |
| 315 | for (const size_t& i : correction_on_indices_[0]) { |
| 316 | correction_on_indices_[3].emplace_back(i); |
| 317 | correction_on_indices_[4].emplace_back(i); |
| 318 | } |
| 319 | } |
| 320 | is_lr_on_ = !not_off_indices_[1].empty() || !not_off_indices_[2].empty() || !correction_on_indices_[1].empty() |
| 321 | || !correction_on_indices_[2].empty(); |
| 322 | is_ms_on_ = !not_off_indices_[3].empty() || !not_off_indices_[4].empty() || !correction_on_indices_[3].empty() |
| 323 | || !correction_on_indices_[4].empty(); |
| 324 | // get the latency for one correction |
| 325 | int unit_latency = 0; |
| 326 | if (c_filter_structure_ == kMatched) { |
| 327 | unit_latency = match_corrections_[0].getLatency(); |
| 328 | } else if (c_filter_structure_ == kMixed) { |
| 329 | unit_latency = mixed_corrections_[0].getLatency(); |
| 330 | } else if (c_filter_structure_ == kZero) { |
| 331 | unit_latency = zero_corrections_[0].getLatency(); |
| 332 | } |
| 333 | // calculate total latency and update |
| 334 | int new_latency = 0; |
| 335 | if (is_lr_on_) { |
| 336 | new_latency += unit_latency; |
| 337 | } else if (is_ms_on_) { |
| 338 | new_latency += unit_latency; |
| 339 | } |
| 340 | if (correction_latency_.exchange(new_latency, std::memory_order::relaxed) != new_latency) { |
| 341 | triggerAsyncUpdate(); |
| 342 | } |
| 343 | std::fill(to_update_correction_.begin(), to_update_correction_.end(), true); |
| 344 | } |
| 345 | |
| 346 | void Controller::prepareCorrection() { |
| 347 | for (const auto& idx : correction_on_total_) { |
nothing calls this directly
no test coverage detected