aboutsummaryrefslogtreecommitdiffstats
path: root/lib/soapy/soapy_sink_c.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/soapy/soapy_sink_c.cc')
-rw-r--r--lib/soapy/soapy_sink_c.cc29
1 files changed, 27 insertions, 2 deletions
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 <iostream>
+#include <algorithm> //find
#include <boost/assign.hpp>
#include <boost/format.hpp>
@@ -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<std::string> 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<std::string> 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<std::string> soapy_sink_c::get_gain_names( size_t chan)