From 2f93c7ae588052919da3db840de2431c69b08cb1 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Sat, 30 Jan 2021 02:21:30 +0100 Subject: [PATCH] Fixed wrong sample rate at startup --- airspy_source/src/main.cpp | 8 ++++++++ airspyhf_source/src/main.cpp | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/airspy_source/src/main.cpp b/airspy_source/src/main.cpp index 07f7862e..87d38aaa 100644 --- a/airspy_source/src/main.cpp +++ b/airspy_source/src/main.cpp @@ -38,12 +38,16 @@ public: handler.stream = &stream; refresh(); + if (sampleRateList.size() > 0) { + sampleRate = sampleRateList[0]; + } // Select device from config config.aquire(); std::string devSerial = config.conf["device"]; config.release(); selectByString(devSerial); + core::setInputSampleRate(sampleRate); sigpath::sourceManager.registerSource("Airspy", &handler); } @@ -145,11 +149,13 @@ public: // Load sample rate srId = 0; + sampleRate = sampleRateList[0]; if (config.conf["devices"][selectedSerStr].contains("sampleRate")) { int selectedSr = config.conf["devices"][selectedSerStr]["sampleRate"]; for (int i = 0; i < sampleRateList.size(); i++) { if (sampleRateList[i] == selectedSr) { srId = i; + sampleRate = selectedSr; break; } } @@ -304,6 +310,7 @@ private: ImGui::SetNextItemWidth(menuWidth); if (ImGui::Combo(CONCAT("##_airspy_dev_sel_", _this->name), &_this->devId, _this->devListTxt.c_str())) { _this->selectBySerial(_this->devList[_this->devId]); + core::setInputSampleRate(_this->sampleRate); if (_this->selectedSerStr != "") { config.aquire(); config.conf["device"] = _this->selectedSerStr; @@ -329,6 +336,7 @@ private: std::string devSerial = config.conf["device"]; config.release(); _this->selectByString(devSerial); + core::setInputSampleRate(_this->sampleRate); } if (_this->running) { style::endDisabled(); } diff --git a/airspyhf_source/src/main.cpp b/airspyhf_source/src/main.cpp index 0071d607..9be478f2 100644 --- a/airspyhf_source/src/main.cpp +++ b/airspyhf_source/src/main.cpp @@ -45,6 +45,7 @@ public: std::string devSerial = config.conf["device"]; config.release(); selectByString(devSerial); + core::setInputSampleRate(sampleRate); sigpath::sourceManager.registerSource("Airspy HF+", &handler); } @@ -146,11 +147,13 @@ public: // Load sample rate srId = 0; + sampleRate = sampleRateList[0]; if (config.conf["devices"][selectedSerStr].contains("sampleRate")) { int selectedSr = config.conf["devices"][selectedSerStr]["sampleRate"]; for (int i = 0; i < sampleRateList.size(); i++) { if (sampleRateList[i] == selectedSr) { srId = i; + sampleRate = selectedSr; break; } } @@ -261,6 +264,7 @@ private: ImGui::SetNextItemWidth(menuWidth); if (ImGui::Combo(CONCAT("##_airspyhf_dev_sel_", _this->name), &_this->devId, _this->devListTxt.c_str())) { _this->selectBySerial(_this->devList[_this->devId]); + core::setInputSampleRate(_this->sampleRate); if (_this->selectedSerStr != "") { config.aquire(); config.conf["device"] = _this->selectedSerStr; @@ -286,6 +290,7 @@ private: std::string devSerial = config.conf["device"]; config.release(); _this->selectByString(devSerial); + core::setInputSampleRate(_this->sampleRate); } if (_this->running) { style::endDisabled(); }