Fixed wrong sample rate at startup

pull/66/head
Ryzerth 2021-01-30 02:21:30 +01:00
rodzic 4abfe407da
commit 2f93c7ae58
2 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

@ -38,12 +38,16 @@ public:
handler.stream = &stream; handler.stream = &stream;
refresh(); refresh();
if (sampleRateList.size() > 0) {
sampleRate = sampleRateList[0];
}
// Select device from config // Select device from config
config.aquire(); config.aquire();
std::string devSerial = config.conf["device"]; std::string devSerial = config.conf["device"];
config.release(); config.release();
selectByString(devSerial); selectByString(devSerial);
core::setInputSampleRate(sampleRate);
sigpath::sourceManager.registerSource("Airspy", &handler); sigpath::sourceManager.registerSource("Airspy", &handler);
} }
@ -145,11 +149,13 @@ public:
// Load sample rate // Load sample rate
srId = 0; srId = 0;
sampleRate = sampleRateList[0];
if (config.conf["devices"][selectedSerStr].contains("sampleRate")) { if (config.conf["devices"][selectedSerStr].contains("sampleRate")) {
int selectedSr = config.conf["devices"][selectedSerStr]["sampleRate"]; int selectedSr = config.conf["devices"][selectedSerStr]["sampleRate"];
for (int i = 0; i < sampleRateList.size(); i++) { for (int i = 0; i < sampleRateList.size(); i++) {
if (sampleRateList[i] == selectedSr) { if (sampleRateList[i] == selectedSr) {
srId = i; srId = i;
sampleRate = selectedSr;
break; break;
} }
} }
@ -304,6 +310,7 @@ private:
ImGui::SetNextItemWidth(menuWidth); ImGui::SetNextItemWidth(menuWidth);
if (ImGui::Combo(CONCAT("##_airspy_dev_sel_", _this->name), &_this->devId, _this->devListTxt.c_str())) { if (ImGui::Combo(CONCAT("##_airspy_dev_sel_", _this->name), &_this->devId, _this->devListTxt.c_str())) {
_this->selectBySerial(_this->devList[_this->devId]); _this->selectBySerial(_this->devList[_this->devId]);
core::setInputSampleRate(_this->sampleRate);
if (_this->selectedSerStr != "") { if (_this->selectedSerStr != "") {
config.aquire(); config.aquire();
config.conf["device"] = _this->selectedSerStr; config.conf["device"] = _this->selectedSerStr;
@ -329,6 +336,7 @@ private:
std::string devSerial = config.conf["device"]; std::string devSerial = config.conf["device"];
config.release(); config.release();
_this->selectByString(devSerial); _this->selectByString(devSerial);
core::setInputSampleRate(_this->sampleRate);
} }
if (_this->running) { style::endDisabled(); } if (_this->running) { style::endDisabled(); }

Wyświetl plik

@ -45,6 +45,7 @@ public:
std::string devSerial = config.conf["device"]; std::string devSerial = config.conf["device"];
config.release(); config.release();
selectByString(devSerial); selectByString(devSerial);
core::setInputSampleRate(sampleRate);
sigpath::sourceManager.registerSource("Airspy HF+", &handler); sigpath::sourceManager.registerSource("Airspy HF+", &handler);
} }
@ -146,11 +147,13 @@ public:
// Load sample rate // Load sample rate
srId = 0; srId = 0;
sampleRate = sampleRateList[0];
if (config.conf["devices"][selectedSerStr].contains("sampleRate")) { if (config.conf["devices"][selectedSerStr].contains("sampleRate")) {
int selectedSr = config.conf["devices"][selectedSerStr]["sampleRate"]; int selectedSr = config.conf["devices"][selectedSerStr]["sampleRate"];
for (int i = 0; i < sampleRateList.size(); i++) { for (int i = 0; i < sampleRateList.size(); i++) {
if (sampleRateList[i] == selectedSr) { if (sampleRateList[i] == selectedSr) {
srId = i; srId = i;
sampleRate = selectedSr;
break; break;
} }
} }
@ -261,6 +264,7 @@ private:
ImGui::SetNextItemWidth(menuWidth); ImGui::SetNextItemWidth(menuWidth);
if (ImGui::Combo(CONCAT("##_airspyhf_dev_sel_", _this->name), &_this->devId, _this->devListTxt.c_str())) { if (ImGui::Combo(CONCAT("##_airspyhf_dev_sel_", _this->name), &_this->devId, _this->devListTxt.c_str())) {
_this->selectBySerial(_this->devList[_this->devId]); _this->selectBySerial(_this->devList[_this->devId]);
core::setInputSampleRate(_this->sampleRate);
if (_this->selectedSerStr != "") { if (_this->selectedSerStr != "") {
config.aquire(); config.aquire();
config.conf["device"] = _this->selectedSerStr; config.conf["device"] = _this->selectedSerStr;
@ -286,6 +290,7 @@ private:
std::string devSerial = config.conf["device"]; std::string devSerial = config.conf["device"];
config.release(); config.release();
_this->selectByString(devSerial); _this->selectByString(devSerial);
core::setInputSampleRate(_this->sampleRate);
} }
if (_this->running) { style::endDisabled(); } if (_this->running) { style::endDisabled(); }