aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2017-04-14 10:57:16 -0500
committerJosh Blum <josh@joshknows.com>2017-04-18 16:29:02 -0700
commitb361fa5a7768864901821567bba0f89a18646b9e (patch)
tree21a1604d01365a040d7651f88d234cfbba29a111
parenta9e536f45bae3c283a1ad7ed13ff17bbda6173ba (diff)
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.
-rw-r--r--lib/soapy/soapy_sink_c.cc7
-rw-r--r--lib/soapy/soapy_source_c.cc7
2 files changed, 14 insertions, 0 deletions
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;
}