aboutsummaryrefslogtreecommitdiffstats
path: root/lib/soapy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/soapy')
-rw-r--r--lib/soapy/CMakeLists.txt23
-rw-r--r--lib/soapy/soapy_common.cc4
-rw-r--r--lib/soapy/soapy_common.h5
-rw-r--r--lib/soapy/soapy_sink_c.cc16
-rw-r--r--lib/soapy/soapy_source_c.cc27
5 files changed, 35 insertions, 40 deletions
diff --git a/lib/soapy/CMakeLists.txt b/lib/soapy/CMakeLists.txt
index 7ac4d69..338bcaf 100644
--- a/lib/soapy/CMakeLists.txt
+++ b/lib/soapy/CMakeLists.txt
@@ -1,19 +1,19 @@
# Copyright 2015 Free Software Foundation, Inc.
#
-# This file is part of gr-osmosdr
+# This file is part of GNU Radio
#
-# gr-osmosdr is free software; you can redistribute it and/or modify
+# GNU Radio is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
-# gr-osmosdr is distributed in the hope that it will be useful,
+# GNU Radio is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with gr-osmosdr; see the file COPYING. If not, write to
+# along with GNU Radio; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
@@ -21,18 +21,19 @@
# This file included, use CMake directory variables
########################################################################
-target_include_directories(gnuradio-osmosdr PRIVATE
+include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${SoapySDR_INCLUDE_DIRS}
)
-APPEND_LIB_LIST(
- ${SoapySDR_LIBRARIES}
-)
-
-list(APPEND gr_osmosdr_srcs
+set(soapy_srcs
${CMAKE_CURRENT_SOURCE_DIR}/soapy_common.cc
${CMAKE_CURRENT_SOURCE_DIR}/soapy_source_c.cc
${CMAKE_CURRENT_SOURCE_DIR}/soapy_sink_c.cc
)
-set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE)
+
+########################################################################
+# Append gnuradio-osmosdr library sources
+########################################################################
+list(APPEND gr_osmosdr_srcs ${soapy_srcs})
+list(APPEND gr_osmosdr_libs ${SoapySDR_LIBRARIES})
diff --git a/lib/soapy/soapy_common.cc b/lib/soapy/soapy_common.cc
index e241967..0e277e4 100644
--- a/lib/soapy/soapy_common.cc
+++ b/lib/soapy/soapy_common.cc
@@ -36,8 +36,8 @@ osmosdr::gain_range_t soapy_range_to_gain_range(const SoapySDR::Range &r)
return osmosdr::gain_range_t(r.minimum(), r.maximum(), step);
}
-std::mutex &get_soapy_maker_mutex(void)
+boost::mutex &get_soapy_maker_mutex(void)
{
- static std::mutex m;
+ static boost::mutex m;
return m;
}
diff --git a/lib/soapy/soapy_common.h b/lib/soapy/soapy_common.h
index 8adb0db..87e46a5 100644
--- a/lib/soapy/soapy_common.h
+++ b/lib/soapy/soapy_common.h
@@ -23,8 +23,7 @@
#include <osmosdr/ranges.h>
#include <SoapySDR/Types.hpp>
-
-#include <mutex>
+#include <boost/thread/mutex.hpp>
/*!
* Convert a soapy range to a gain range.
@@ -36,6 +35,6 @@ osmosdr::gain_range_t soapy_range_to_gain_range(const SoapySDR::Range &r);
* Global mutex to protect factory routines.
* (optional under 0.5 release above)
*/
-std::mutex &get_soapy_maker_mutex(void);
+boost::mutex &get_soapy_maker_mutex(void);
#endif /* INCLUDED_SOAPY_COMMON_H */
diff --git a/lib/soapy/soapy_sink_c.cc b/lib/soapy/soapy_sink_c.cc
index 4aafc47..b12b8da 100644
--- a/lib/soapy/soapy_sink_c.cc
+++ b/lib/soapy/soapy_sink_c.cc
@@ -63,7 +63,7 @@ soapy_sink_c::soapy_sink_c (const std::string &args)
gr::io_signature::make (0, 0, 0))
{
{
- std::lock_guard<std::mutex> l(get_soapy_maker_mutex());
+ boost::mutex::scoped_lock l(get_soapy_maker_mutex());
_device = SoapySDR::Device::make(params_to_dict(args));
}
_nchan = std::max(1, args_to_io_signature(args)->max_streams());
@@ -75,7 +75,7 @@ soapy_sink_c::soapy_sink_c (const std::string &args)
soapy_sink_c::~soapy_sink_c(void)
{
_device->closeStream(_stream);
- std::lock_guard<std::mutex> l(get_soapy_maker_mutex());
+ boost::mutex::scoped_lock l(get_soapy_maker_mutex());
SoapySDR::Device::unmake(_device);
}
@@ -107,7 +107,7 @@ std::vector<std::string> soapy_sink_c::get_devices()
{
std::vector<std::string> result;
int i = 0;
- for (SoapySDR::Kwargs kw : SoapySDR::Device::enumerate())
+ BOOST_FOREACH(SoapySDR::Kwargs kw, SoapySDR::Device::enumerate())
{
kw["soapy"] = boost::lexical_cast<std::string>(i++);
result.push_back(dict_to_args_string(kw));
@@ -124,12 +124,12 @@ 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
- for (const SoapySDR::Range &r : _device->getSampleRateRange(SOAPY_SDR_TX, 0))
+ BOOST_FOREACH(const SoapySDR::Range &r, _device->getSampleRateRange(SOAPY_SDR_TX, 0))
{
result.push_back(osmosdr::range_t(r.minimum(), r.maximum()));
}
#else
- for (const double rate : _device->listSampleRates(SOAPY_SDR_TX, 0))
+ BOOST_FOREACH(const double rate, _device->listSampleRates(SOAPY_SDR_TX, 0))
{
result.push_back(osmosdr::range_t(rate));
}
@@ -151,7 +151,7 @@ double soapy_sink_c::get_sample_rate( void )
osmosdr::freq_range_t soapy_sink_c::get_freq_range( size_t chan)
{
osmosdr::meta_range_t result;
- for (const SoapySDR::Range r : _device->getFrequencyRange(SOAPY_SDR_TX, 0))
+ BOOST_FOREACH(const SoapySDR::Range r, _device->getFrequencyRange(SOAPY_SDR_TX, 0))
{
result.push_back(osmosdr::range_t(r.minimum(), r.maximum()));
}
@@ -309,12 +309,12 @@ osmosdr::freq_range_t soapy_sink_c::get_bandwidth_range( size_t chan)
{
osmosdr::meta_range_t result;
#ifdef SOAPY_SDR_API_HAS_GET_BANDWIDTH_RANGE
- for (const SoapySDR::Range &r : _device->getBandwidthRange(SOAPY_SDR_TX, 0))
+ BOOST_FOREACH(const SoapySDR::Range &r, _device->getBandwidthRange(SOAPY_SDR_TX, 0))
{
result.push_back(osmosdr::range_t(r.minimum(), r.maximum()));
}
#else
- for (const double bw : _device->listBandwidths(SOAPY_SDR_TX, 0))
+ BOOST_FOREACH(const double bw, _device->listBandwidths(SOAPY_SDR_TX, 0))
{
result.push_back(osmosdr::range_t(bw));
}
diff --git a/lib/soapy/soapy_source_c.cc b/lib/soapy/soapy_source_c.cc
index 4dc9efc..a645361 100644
--- a/lib/soapy/soapy_source_c.cc
+++ b/lib/soapy/soapy_source_c.cc
@@ -64,7 +64,7 @@ soapy_source_c::soapy_source_c (const std::string &args)
args_to_io_signature(args))
{
{
- std::lock_guard<std::mutex> l(get_soapy_maker_mutex());
+ boost::mutex::scoped_lock l(get_soapy_maker_mutex());
_device = SoapySDR::Device::make(params_to_dict(args));
}
_nchan = std::max(1, args_to_io_signature(args)->max_streams());
@@ -76,7 +76,7 @@ soapy_source_c::soapy_source_c (const std::string &args)
soapy_source_c::~soapy_source_c(void)
{
_device->closeStream(_stream);
- std::lock_guard<std::mutex> l(get_soapy_maker_mutex());
+ boost::mutex::scoped_lock l(get_soapy_maker_mutex());
SoapySDR::Device::unmake(_device);
}
@@ -96,14 +96,9 @@ int soapy_source_c::work( int noutput_items,
{
int flags = 0;
long long timeNs = 0;
- int ret;
- int retries = 1;
-
- do {
- ret = _device->readStream(
- _stream, &output_items[0],
- noutput_items, flags, timeNs);
- } while (retries-- && (ret == SOAPY_SDR_OVERFLOW));
+ int ret = _device->readStream(
+ _stream, &output_items[0],
+ noutput_items, flags, timeNs);
if (ret < 0) return 0; //call again
return ret;
@@ -113,7 +108,7 @@ std::vector<std::string> soapy_source_c::get_devices()
{
std::vector<std::string> result;
int i = 0;
- for (SoapySDR::Kwargs kw : SoapySDR::Device::enumerate())
+ BOOST_FOREACH(SoapySDR::Kwargs kw, SoapySDR::Device::enumerate())
{
kw["soapy"] = boost::lexical_cast<std::string>(i++);
result.push_back(dict_to_args_string(kw));
@@ -130,12 +125,12 @@ 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
- for (const SoapySDR::Range &r : _device->getSampleRateRange(SOAPY_SDR_RX, 0))
+ BOOST_FOREACH(const SoapySDR::Range &r, _device->getSampleRateRange(SOAPY_SDR_RX, 0))
{
result.push_back(osmosdr::range_t(r.minimum(), r.maximum()));
}
#else
- for (const double rate : _device->listSampleRates(SOAPY_SDR_RX, 0))
+ BOOST_FOREACH(const double rate, _device->listSampleRates(SOAPY_SDR_RX, 0))
{
result.push_back(osmosdr::range_t(rate));
}
@@ -157,7 +152,7 @@ double soapy_source_c::get_sample_rate( void )
osmosdr::freq_range_t soapy_source_c::get_freq_range( size_t chan )
{
osmosdr::meta_range_t result;
- for (const SoapySDR::Range r : _device->getFrequencyRange(SOAPY_SDR_RX, 0))
+ BOOST_FOREACH(const SoapySDR::Range r, _device->getFrequencyRange(SOAPY_SDR_RX, 0))
{
result.push_back(osmosdr::range_t(r.minimum(), r.maximum()));
}
@@ -338,12 +333,12 @@ osmosdr::freq_range_t soapy_source_c::get_bandwidth_range( size_t chan )
{
osmosdr::meta_range_t result;
#ifdef SOAPY_SDR_API_HAS_GET_BANDWIDTH_RANGE
- for (const SoapySDR::Range &r : _device->getBandwidthRange(SOAPY_SDR_RX, 0))
+ BOOST_FOREACH(const SoapySDR::Range &r, _device->getBandwidthRange(SOAPY_SDR_RX, 0))
{
result.push_back(osmosdr::range_t(r.minimum(), r.maximum()));
}
#else
- for (const double bw : _device->listBandwidths(SOAPY_SDR_RX, 0))
+ BOOST_FOREACH(const double bw, _device->listBandwidths(SOAPY_SDR_RX, 0))
{
result.push_back(osmosdr::range_t(bw));
}