aboutsummaryrefslogtreecommitdiffstats
path: root/lib/airspy/airspy_source_c.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/airspy/airspy_source_c.cc')
-rw-r--r--lib/airspy/airspy_source_c.cc25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/airspy/airspy_source_c.cc b/lib/airspy/airspy_source_c.cc
index bbeb3aa..50150e5 100644
--- a/lib/airspy/airspy_source_c.cc
+++ b/lib/airspy/airspy_source_c.cc
@@ -46,13 +46,18 @@
using namespace boost::assign;
+#define AIRSPY_FORMAT_ERROR(ret, msg) \
+ boost::str( boost::format(msg " (%1%) %2%") \
+ % ret % airspy_error_name((enum airspy_error)ret) )
+
#define AIRSPY_THROW_ON_ERROR(ret, msg) \
- if ( ret != AIRSPY_SUCCESS ) \
- throw std::runtime_error( boost::str( boost::format(msg " (%d) %s") \
- % ret % airspy_error_name((enum airspy_error)ret) ) );
+ if ( ret != AIRSPY_SUCCESS ) \
+ { \
+ throw std::runtime_error( AIRSPY_FORMAT_ERROR(ret, msg) ); \
+ }
#define AIRSPY_FUNC_STR(func, arg) \
- boost::str(boost::format(func "(%d)") % arg) + " has failed"
+ boost::str(boost::format(func "(%1%)") % arg) + " has failed"
airspy_source_c_sptr make_airspy_source_c (const std::string & args)
{
@@ -182,11 +187,17 @@ airspy_source_c::~airspy_source_c ()
if ( airspy_is_streaming( _dev ) == AIRSPY_TRUE )
{
ret = airspy_stop_rx( _dev );
- AIRSPY_THROW_ON_ERROR(ret, "Failed to stop RX streaming")
+ if ( ret != AIRSPY_SUCCESS )
+ {
+ std::cerr << AIRSPY_FORMAT_ERROR(ret, "Failed to stop RX streaming") << std::endl;
+ }
}
ret = airspy_close( _dev );
- AIRSPY_THROW_ON_ERROR(ret, "Failed to close AirSpy")
+ if ( ret != AIRSPY_SUCCESS )
+ {
+ std::cerr << AIRSPY_FORMAT_ERROR(ret, "Failed to close AirSpy") << std::endl;
+ }
_dev = NULL;
}
@@ -678,7 +689,7 @@ double airspy_source_c::set_bandwidth( double bandwidth, size_t chan )
if (size)
{
- std::cout << " Airspy decim:" << decim
+ std::cerr << " Airspy decim:" << decim
<< " kernel size:" << size << std::endl;
ret = airspy_set_conversion_filter_float32(_dev, kernel, size);
AIRSPY_THROW_ON_ERROR(ret, "Failed to set IQ conversion filter")