From 59736a5bf512db83a6bd7250e14b13c7464770fc Mon Sep 17 00:00:00 2001
From: Martin Braun <martin.braun@ettus.com>
Date: Wed, 6 Sep 2017 22:28:41 -0700
Subject: C API: Better error handling in uhd_usrp_get_?x_stream

In uhd_usrp_get_rx_stream and uhd_usrp_get_tx_stream, an error will now
be propagated into the streamer handle.
---
 host/lib/usrp/usrp_c.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'host/lib/usrp')

diff --git a/host/lib/usrp/usrp_c.cpp b/host/lib/usrp/usrp_c.cpp
index 5536c7946..13b4b607b 100644
--- a/host/lib/usrp/usrp_c.cpp
+++ b/host/lib/usrp/usrp_c.cpp
@@ -323,10 +323,11 @@ uhd_error uhd_usrp_get_rx_stream(
     uhd_stream_args_t *stream_args,
     uhd_rx_streamer_handle h_s
 ){
-    UHD_SAFE_C(
+    UHD_SAFE_C_SAVE_ERROR(h_s,
         boost::mutex::scoped_lock lock(_usrp_get_rx_stream_mutex);
 
         if(!get_usrp_ptrs().count(h_u->usrp_index)){
+            h_s->last_error = "Streamer's device is invalid or expired.";
             return UHD_ERROR_INVALID_DEVICE;
         }
 
@@ -345,10 +346,11 @@ uhd_error uhd_usrp_get_tx_stream(
     uhd_stream_args_t *stream_args,
     uhd_tx_streamer_handle h_s
 ){
-    UHD_SAFE_C(
+    UHD_SAFE_C_SAVE_ERROR(h_s,
         boost::mutex::scoped_lock lock(_usrp_get_tx_stream_mutex);
 
         if(!get_usrp_ptrs().count(h_u->usrp_index)){
+            h_s->last_error = "Streamer's device is invalid or expired.";
             return UHD_ERROR_INVALID_DEVICE;
         }
 
-- 
cgit v1.2.3