Skip to content

Commit

Permalink
It seems that rtlsdr_set_bias_tee() is not available under some condi…
Browse files Browse the repository at this point in the history
…tions and the error handling was not working correctly which results in a seg fault on Windows systems. Try to improve it.
  • Loading branch information
AlbrechtL committed Sep 2, 2024
1 parent 3dbd860 commit 6736a94
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/input/rtl_sdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@
#define READLEN_DEFAULT 8192

// Fallback if function is not defined in shared lib
int __attribute__((weak)) rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on);
int __attribute__((weak)) rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on)
{
(void) dev;
(void) on;
std::clog << "RTL_SDR: " << "Error: rtlsdr_set_bias_tee() not defined!" << std::endl;
return false;
}

CRTL_SDR::CRTL_SDR(RadioControllerInterface& radioController) :
radioController(radioController),
Expand Down Expand Up @@ -230,15 +236,10 @@ bool CRTL_SDR::setDeviceParam(DeviceParam param, int value)
{
switch(param) {
case DeviceParam::BiasTee:
if(rtlsdr_set_bias_tee)
{
std::clog << "RTL_SDR: "<< "Set bias tee to " << value << std::endl;
rtlsdr_set_bias_tee(device, value);
}
else
{
std::clog << "RTL_SDR: " << "Error: rtlsdr_set_bias_tee() not defined!" << std::endl;
}
return true;

default: std::runtime_error("Unsupported device parameter");
Expand Down

0 comments on commit 6736a94

Please sign in to comment.