diff --git a/lib/soapy/soapy_sink_c.cc b/lib/soapy/soapy_sink_c.cc index 1af5a65..b12b8da 100644 --- a/lib/soapy/soapy_sink_c.cc +++ b/lib/soapy/soapy_sink_c.cc @@ -29,6 +29,7 @@ #endif #include +#include //find #include #include @@ -122,10 +123,17 @@ size_t soapy_sink_c::get_num_channels( void ) osmosdr::meta_range_t soapy_sink_c::get_sample_rates( void ) { osmosdr::meta_range_t result; + #ifdef SOAPY_SDR_API_HAS_GET_SAMPLE_RATE_RANGE + BOOST_FOREACH(const SoapySDR::Range &r, _device->getSampleRateRange(SOAPY_SDR_TX, 0)) + { + result.push_back(osmosdr::range_t(r.minimum(), r.maximum())); + } + #else BOOST_FOREACH(const double rate, _device->listSampleRates(SOAPY_SDR_TX, 0)) { result.push_back(osmosdr::range_t(rate)); } + #endif return result; } @@ -163,13 +171,30 @@ double soapy_sink_c::get_center_freq( size_t chan) double soapy_sink_c::set_freq_corr( double ppm, size_t chan) { - _device->setFrequency(SOAPY_SDR_TX, chan, "CORR", ppm); + #ifdef SOAPY_SDR_API_HAS_FREQUENCY_CORRECTION_API + _device->setFrequencyCorrection(SOAPY_SDR_TX, chan, ppm); + #else + std::vector components = _device->listFrequencies(SOAPY_SDR_TX, chan); + if (std::find(components.begin(), components.end(), "CORR") != components.end()) + { + _device->setFrequency(SOAPY_SDR_TX, chan, "CORR", ppm); + } + #endif return this->get_freq_corr(chan); } double soapy_sink_c::get_freq_corr( size_t chan) { - return _device->getFrequency(SOAPY_SDR_TX, chan, "CORR"); + #ifdef SOAPY_SDR_API_HAS_FREQUENCY_CORRECTION_API + return _device->getFrequencyCorrection(SOAPY_SDR_TX, chan); + #else + std::vector components = _device->listFrequencies(SOAPY_SDR_TX, chan); + if (std::find(components.begin(), components.end(), "CORR") != components.end()) + { + return _device->getFrequency(SOAPY_SDR_TX, chan, "CORR"); + } + return 0.0; + #endif } std::vector soapy_sink_c::get_gain_names( size_t chan) diff --git a/lib/soapy/soapy_source_c.cc b/lib/soapy/soapy_source_c.cc index d066ed8..a645361 100644 --- a/lib/soapy/soapy_source_c.cc +++ b/lib/soapy/soapy_source_c.cc @@ -29,6 +29,7 @@ #endif #include +#include //find #include #include @@ -123,10 +124,17 @@ size_t soapy_source_c::get_num_channels( void ) osmosdr::meta_range_t soapy_source_c::get_sample_rates( void ) { osmosdr::meta_range_t result; + #ifdef SOAPY_SDR_API_HAS_GET_SAMPLE_RATE_RANGE + BOOST_FOREACH(const SoapySDR::Range &r, _device->getSampleRateRange(SOAPY_SDR_RX, 0)) + { + result.push_back(osmosdr::range_t(r.minimum(), r.maximum())); + } + #else BOOST_FOREACH(const double rate, _device->listSampleRates(SOAPY_SDR_RX, 0)) { result.push_back(osmosdr::range_t(rate)); } + #endif return result; } @@ -164,13 +172,30 @@ double soapy_source_c::get_center_freq( size_t chan ) double soapy_source_c::set_freq_corr( double ppm, size_t chan ) { - _device->setFrequency(SOAPY_SDR_RX, chan, "CORR", ppm); + #ifdef SOAPY_SDR_API_HAS_FREQUENCY_CORRECTION_API + _device->setFrequencyCorrection(SOAPY_SDR_RX, chan, ppm); + #else + std::vector components = _device->listFrequencies(SOAPY_SDR_RX, chan); + if (std::find(components.begin(), components.end(), "CORR") != components.end()) + { + _device->setFrequency(SOAPY_SDR_RX, chan, "CORR", ppm); + } + #endif return this->get_freq_corr(chan); } double soapy_source_c::get_freq_corr( size_t chan ) { - return _device->getFrequency(SOAPY_SDR_RX, chan, "CORR"); + #ifdef SOAPY_SDR_API_HAS_FREQUENCY_CORRECTION_API + return _device->getFrequencyCorrection(SOAPY_SDR_RX, chan); + #else + std::vector components = _device->listFrequencies(SOAPY_SDR_RX, chan); + if (std::find(components.begin(), components.end(), "CORR") != components.end()) + { + return _device->getFrequency(SOAPY_SDR_RX, chan, "CORR"); + } + return 0.0; + #endif } std::vector soapy_source_c::get_gain_names( size_t chan )