| 210 | |
| 211 | |
| 212 | void SpectrumVisualProcessor::process() { |
| 213 | if (!isOutputEmpty()) { |
| 214 | return; |
| 215 | } |
| 216 | if (!input || input->empty()) { |
| 217 | return; |
| 218 | } |
| 219 | |
| 220 | bool executeSetup = false; |
| 221 | |
| 222 | { // scoped lock here |
| 223 | std::lock_guard < std::mutex > busy_lock(busy_run); |
| 224 | if (fftSizeChanged) { |
| 225 | executeSetup = true; |
| 226 | fftSizeChanged = false; |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | if (executeSetup) { |
| 231 | setup(newFFTSize); |
| 232 | } |
| 233 | |
| 234 | DemodulatorThreadIQDataPtr iqData; |
| 235 | |
| 236 | if (!input->pop(iqData, HEARTBEAT_CHECK_PERIOD_MICROS)) { |
| 237 | return; |
| 238 | } |
| 239 | |
| 240 | if (!iqData) { |
| 241 | return; |
| 242 | } |
| 243 | |
| 244 | //then get the busy_lock for the rest of the processing. |
| 245 | std::lock_guard < std::mutex > busy_lock(busy_run); |
| 246 | |
| 247 | bool doPeak = peakHold && (peakReset == 0); |
| 248 | |
| 249 | if (fft_result.size() != fftSizeInternal) { |
| 250 | |
| 251 | if (fft_result.capacity() < fftSizeInternal) { |
| 252 | fft_result.reserve(fftSizeInternal); |
| 253 | fft_result_ma.reserve(fftSizeInternal); |
| 254 | fft_result_maa.reserve(fftSizeInternal); |
| 255 | fft_result_peak.reserve(fftSizeInternal); |
| 256 | } |
| 257 | fft_result.resize(fftSizeInternal); |
| 258 | fft_result_ma.resize(fftSizeInternal); |
| 259 | fft_result_maa.resize(fftSizeInternal); |
| 260 | fft_result_temp.resize(fftSizeInternal); |
| 261 | fft_result_peak.resize(fftSizeInternal); |
| 262 | } |
| 263 | |
| 264 | if (peakReset != 0) { |
| 265 | peakReset--; |
| 266 | if (peakReset == 0) { |
| 267 | for (unsigned int i = 0, iMax = fftSizeInternal; i < iMax; i++) { |
| 268 | fft_result_peak[i] = fft_floor_maa; |
| 269 | } |