From d12021fc2fee92d76e9b7020785af62980d39cd4 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Mon, 8 Apr 2024 16:37:03 +0200 Subject: [PATCH] potential fix for #1361 --- source_modules/soapy_source/src/main.cpp | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/source_modules/soapy_source/src/main.cpp b/source_modules/soapy_source/src/main.cpp index 7274024a..914bb287 100644 --- a/source_modules/soapy_source/src/main.cpp +++ b/source_modules/soapy_source/src/main.cpp @@ -81,8 +81,15 @@ public: private: void refresh() { - devList = SoapySDR::Device::enumerate(); txtDevList = ""; + try { + devList = SoapySDR::Device::enumerate(); + } + catch (const std::exception& e) { + flog::error("Could not list devices: {}", e.what()); + return; + } + int i = 0; for (auto& dev : devList) { txtDevList += dev["label"] != "" ? dev["label"] : dev["driver"]; @@ -153,7 +160,14 @@ private: return; } - SoapySDR::Device* dev = SoapySDR::Device::make(devArgs); + SoapySDR::Device* dev = NULL; + try { + dev = SoapySDR::Device::make(devArgs); + } + catch (const std::exception& e) { + flog::error("Could not open device: {}", e.what()); + return; + } antennaList = dev->listAntennas(SOAPY_SDR_RX, channelId); txtAntennaList = ""; @@ -307,7 +321,13 @@ private: return; } - _this->dev = SoapySDR::Device::make(_this->devArgs); + try { + _this->dev = SoapySDR::Device::make(_this->devArgs); + } + catch (const std::exception& e) { + flog::error("Failed to open device: {}", e.what()); + return; + } _this->dev->setSampleRate(SOAPY_SDR_RX, _this->channelId, _this->sampleRate);