From b361fa5a7768864901821567bba0f89a18646b9e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 14 Apr 2017 10:57:16 -0500 Subject: [PATCH] soapy: support newer getSampleRateRange() API call Switch to the newer API call which can provide a list of ranges. There are feature detection ifdefs provided by the library so that code will always correctly compile. --- lib/soapy/soapy_sink_c.cc | 7 +++++++ lib/soapy/soapy_source_c.cc | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/lib/soapy/soapy_sink_c.cc b/lib/soapy/soapy_sink_c.cc index dbdfa7e..29defea 100644 --- a/lib/soapy/soapy_sink_c.cc +++ b/lib/soapy/soapy_sink_c.cc @@ -123,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; } diff --git a/lib/soapy/soapy_source_c.cc b/lib/soapy/soapy_source_c.cc index fe1e8d9..a1a1885 100644 --- a/lib/soapy/soapy_source_c.cc +++ b/lib/soapy/soapy_source_c.cc @@ -124,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; }