From 03dc5d204250709ade0eed460f0340bc19a0b054 Mon Sep 17 00:00:00 2001 From: Ryzerth Date: Sun, 16 Aug 2020 18:06:21 +0200 Subject: [PATCH] Fixed SoapySDR trying to set gain on no device --- CMakeLists.txt | 4 ++-- src/io/soapy.h | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 17d42566..11daabd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/io/soapy.h b/src/io/soapy.h index 16ddb7ac..3be8f102 100644 --- a/src/io/soapy.h +++ b/src/io/soapy.h @@ -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); }