Fixed wrong sample rate at startup

This commit is contained in:
Ryzerth 2021-01-30 02:21:30 +01:00
parent 4abfe407da
commit 2f93c7ae58
2 changed files with 13 additions and 0 deletions

View File

@ -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(); }

View File

@ -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(); }