Fixed SoapySDR trying to set gain on no device

This commit is contained in:
Ryzerth 2020-08-16 18:06:21 +02:00
parent 19e07eb767
commit 03dc5d2042
2 changed files with 10 additions and 3 deletions

View File

@ -7,8 +7,8 @@ if (MSVC)
include_directories(sdrpp "C:/Program Files/PothosSDR/include/volk/")
include_directories(sdrpp "C:/Program Files/PothosSDR/include/")
else()
# set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fpremissive -fsanitize=address -g")
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fpremissive")
set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fpermissive -fsanitize=address -g")
# set(CMAKE_CXX_FLAGS "-O3 -std=c++17 -fpermissive")
include_directories(sdrpp "/usr/include/volk")
link_libraries(pthread)
link_libraries(GL)

View File

@ -15,6 +15,7 @@ namespace io {
currentGains = new float[1];
refresh();
if (devList.size() == 0) {
dev = NULL;
return;
}
setDevice(devList[0]);
@ -96,7 +97,7 @@ namespace io {
}
void setSampleRate(float sampleRate) {
if (running) {
if (running || dev == NULL) {
return;
}
_sampleRate = sampleRate;
@ -104,10 +105,16 @@ namespace io {
}
void setFrequency(float freq) {
if (dev == NULL) {
return;
}
dev->setFrequency(SOAPY_SDR_RX, 0, freq);
}
void setGain(int gainId, float gain) {
if (dev == NULL) {
return;
}
currentGains[gainId] = gain;
dev->setGain(SOAPY_SDR_RX, 0, gainList[gainId], gain);
}