void SDRThread::updateSettings() { bool doUpdate = false; if (offset_changed.load()) { if (!freq_changed.load()) { frequency.store(frequency.load()); freq_changed.store(true); } offset_changed.store(false); } if (rate_changed.load()) { device->setSampleRate(SOAPY_SDR_RX,0,sampleRate.load()); sampleRate.store(device->getSampleRate(SOAPY_SDR_RX,0)); numChannels.store(getOptimalChannelCount(sampleRate.load())); numElems.store(getOptimalElementCount(sampleRate.load(), 60)); int streamMTU = device->getStreamMTU(stream); mtuElems.store(streamMTU); if (!mtuElems.load()) { mtuElems.store(numElems.load()); } inpBuffer.data.resize(numElems.load()); overflowBuffer.data.resize(mtuElems.load()); free(buffs[0]); buffs[0] = malloc(mtuElems.load() * 4 * sizeof(float)); numOverflow = 0; rate_changed.store(false); doUpdate = true; } if (ppm_changed.load() && hasPPM.load()) { device->setFrequency(SOAPY_SDR_RX,0,"CORR",ppm.load()); ppm_changed.store(false); } if (freq_changed.load()) { if (frequency_locked.load() && !frequency_lock_init.load()) { device->setFrequency(SOAPY_SDR_RX,0,"RF",lock_freq.load()); frequency_lock_init.store(true); } else if (!frequency_locked.load()) { device->setFrequency(SOAPY_SDR_RX,0,"RF",frequency.load() - offset.load()); } freq_changed.store(false); } // double devFreq = device->getFrequency(SOAPY_SDR_RX,0); // if (((long long)devFreq + offset.load()) != frequency.load()) { // wxGetApp().setFrequency((long long)devFreq + offset.load()); // } if (agc_mode_changed.load()) { device->setGainMode(SOAPY_SDR_RX, 0, agc_mode.load()); agc_mode_changed.store(false); if (!agc_mode.load()) { updateGains(); DeviceConfig *devConfig = deviceConfig.load(); ConfigGains gains = devConfig->getGains(); if (gains.size()) { for (ConfigGains::iterator gain_i = gains.begin(); gain_i != gains.end(); gain_i++) { setGain(gain_i->first, gain_i->second); } } } doUpdate = true; } if (gain_value_changed.load() && !agc_mode.load()) { std::lock_guard < std::mutex > lock(gain_busy); for (std::map<std::string,bool>::iterator gci = gainChanged.begin(); gci != gainChanged.end(); gci++) { if (gci->second) { device->setGain(SOAPY_SDR_RX, 0, gci->first, gainValues[gci->first]); gainChanged[gci->first] = false; } } gain_value_changed.store(false); } if (setting_value_changed.load()) { std::lock_guard < std::mutex > lock(setting_busy); for (std::map<std::string, bool>::iterator sci = settingChanged.begin(); sci != settingChanged.end(); sci++) { if (sci->second) { device->writeSetting(sci->first, settings[sci->first]); settingChanged[sci->first] = false; } } setting_value_changed.store(false); doUpdate = true; } if (doUpdate) { wxGetApp().sdrThreadNotify(SDRThread::SDR_THREAD_INITIALIZED, std::string("Settings updated.")); } }