| 448 | } |
| 449 | |
| 450 | void SDRThread::updateSettings() { |
| 451 | bool doUpdate = false; |
| 452 | |
| 453 | if (!stream) { |
| 454 | return; |
| 455 | } |
| 456 | |
| 457 | if (antenna_changed.load()) { |
| 458 | |
| 459 | device->setAntenna(SOAPY_SDR_RX, 0, antennaName); |
| 460 | |
| 461 | antenna_changed.store(false); |
| 462 | } |
| 463 | |
| 464 | if (offset_changed.load()) { |
| 465 | if (!freq_changed.load()) { |
| 466 | frequency.store(frequency.load()); |
| 467 | freq_changed.store(true); |
| 468 | } |
| 469 | offset_changed.store(false); |
| 470 | } |
| 471 | |
| 472 | if (rate_changed.load()) { |
| 473 | |
| 474 | //1. Silence the device: |
| 475 | device->deactivateStream(stream); |
| 476 | |
| 477 | //2. Set the (new) sample rate |
| 478 | try { |
| 479 | device->setSampleRate(SOAPY_SDR_RX, 0, sampleRate.load()); |
| 480 | } |
| 481 | catch (...) { |
| 482 | std::cout << "SDRThread: Exception while setting the sample rate = " << sampleRate.load() << std::endl << std::flush; |
| 483 | } |
| 484 | |
| 485 | //2.3 Device-specific workarounds: |
| 486 | // TODO: explore bandwidth setting option to see if this is necessary for others |
| 487 | if (device->getDriverKey() == "bladeRF") { |
| 488 | device->setBandwidth(SOAPY_SDR_RX, 0, sampleRate.load()); |
| 489 | } |
| 490 | |
| 491 | //3. Re-activate stream: |
| 492 | device->activateStream(stream); |
| 493 | |
| 494 | //4. Re-do Cubic buffers : |
| 495 | //4.1. re-read current sample rate and MTU: |
| 496 | //4.2. The device MAY force another sample rate than the one requested, or refusing the change altogether, |
| 497 | // because of limitations of hardware and the SoapySDR river |
| 498 | double requested_sample_rate = (double)sampleRate.load(); |
| 499 | double applied_sample_rate = device->getSampleRate(SOAPY_SDR_RX, 0); |
| 500 | |
| 501 | if (abs((requested_sample_rate - applied_sample_rate) / requested_sample_rate) > 0.05) { |
| 502 | //force the applied_sample_rate as the new effective user setting |
| 503 | DeviceConfig* devConfig = deviceConfig.load(); |
| 504 | if (devConfig) { |
| 505 | devConfig->setSampleRate(applied_sample_rate); |
| 506 | } |
| 507 |
nothing calls this directly
no test coverage detected