| 129 | } |
| 130 | |
| 131 | void Controller::prepareStatus() { |
| 132 | if (c_filter_structure_ != filter_structure_.load(std::memory_order::relaxed)) { |
| 133 | // cache filter structure |
| 134 | c_filter_structure_ = filter_structure_.load(std::memory_order::relaxed); |
| 135 | c_correction_enabled_ = |
| 136 | (c_filter_structure_ == kMatched) || (c_filter_structure_ == kMixed) || (c_filter_structure_ == kZero); |
| 137 | if (c_correction_enabled_) { |
| 138 | // not zero latency, calculate latency later with LRMS info |
| 139 | to_update_correction_indices_ = true; |
| 140 | std::fill(res_update_flags_.begin(), res_update_flags_.end(), true); |
| 141 | } else if (correction_latency_.exchange(0, std::memory_order::relaxed) != 0) { |
| 142 | // is zero latency, update latency |
| 143 | triggerAsyncUpdate(); |
| 144 | } |
| 145 | // force update all filters |
| 146 | for (size_t i = 0; i < kBandNum; ++i) { |
| 147 | empty_update_flags_[i].signal(); |
| 148 | } |
| 149 | // force reset all filters |
| 150 | for (size_t i = 0; i < kBandNum; ++i) { |
| 151 | tdf_filters_[i].reset(); |
| 152 | svf_filters_[i].reset(); |
| 153 | parallel_filters_[i].reset(); |
| 154 | } |
| 155 | // update lr/ms on flags as they might be changed by corrections |
| 156 | is_lr_on_ = !not_off_indices_[1].empty() || !not_off_indices_[2].empty(); |
| 157 | is_ms_on_ = !not_off_indices_[3].empty() || !not_off_indices_[4].empty(); |
| 158 | std::fill(to_update_correction_.begin(), to_update_correction_.end(), true); |
| 159 | } else { |
| 160 | to_update_correction_indices_ = false; |
| 161 | } |
| 162 | if (to_update_status_.check()) { |
| 163 | // cache total not off indices |
| 164 | not_off_total_.clear(); |
| 165 | for (size_t i = 0; i < kBandNum; ++i) { |
| 166 | c_filter_status_[i] = filter_status_[i].load(std::memory_order::relaxed); |
| 167 | if (c_filter_status_[i] != FilterStatus::kOff) { |
| 168 | not_off_total_.emplace_back(i); |
| 169 | } |
| 170 | } |
| 171 | to_update_lrms_.signal(); |
| 172 | } |
| 173 | if (to_update_solo_.check()) { |
| 174 | // update solo status |
| 175 | const auto solo_whole_idx = solo_whole_idx_.load(std::memory_order::relaxed); |
| 176 | if (solo_whole_idx == 2 * kBandNum) { |
| 177 | c_solo_on_ = false; |
| 178 | } else { |
| 179 | c_solo_on_ = true; |
| 180 | solo_filter_.reset(); |
| 181 | if (solo_whole_idx < kBandNum) { |
| 182 | c_solo_idx_ = solo_whole_idx; |
| 183 | c_solo_side_ = false; |
| 184 | updateSoloFilter<true>(filter_paras_[c_solo_idx_]); |
| 185 | } else { |
| 186 | c_solo_idx_ = solo_whole_idx - kBandNum; |
| 187 | c_solo_side_ = true; |
| 188 | updateSoloFilter<true>(side_filter_paras_[c_solo_idx_]); |