commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 01/12: Check RX/TX streamers::sptr before f


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/12: Check RX/TX streamers::sptr before flush/reset
Date: Tue, 29 Dec 2015 22:49:22 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 4ae7a6015ba719a4720f61cc6f3857de2ebda89f
Author: Marcus Müller <address@hidden>
Date:   Sun Aug 9 21:50:58 2015 +0200

    Check RX/TX streamers::sptr before flush/reset
    
    Current code triggers a segfault when user uses the stream arg setter
    before starting the flowgraph.
    
    Another surprising use case that segfaults is
    
    tb->start();
    usrp_source->stop();
    
    which is a clever way to allow streaming to start when the user calls
    usrp_source->issue_stream_cmd(...) rather than as soon as GNU Radio runs
    without using set_start_time (e.g. when the start time is unknown at FG
    initialization).
---
 gr-uhd/lib/usrp_sink_impl.cc   |  6 ++++--
 gr-uhd/lib/usrp_source_impl.cc | 10 ++++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc
index 64d25bd..666f09c 100644
--- a/gr-uhd/lib/usrp_sink_impl.cc
+++ b/gr-uhd/lib/usrp_sink_impl.cc
@@ -321,7 +321,8 @@ namespace gr {
     {
       _update_stream_args(stream_args);
 #ifdef GR_UHD_USE_STREAM_API
-      _tx_stream.reset();
+      if(_tx_stream)
+        _tx_stream.reset();
 #else
       throw std::runtime_error("not implemented in this version");
 #endif
@@ -609,7 +610,8 @@ namespace gr {
       _nitems_to_send = 0;
 
 #ifdef GR_UHD_USE_STREAM_API
-      _tx_stream->send(gr_vector_const_void_star(_nchan), 0, _metadata, 1.0);
+      if(_tx_stream)
+        _tx_stream->send(gr_vector_const_void_star(_nchan), 0, _metadata, 1.0);
 #else
       _dev->get_device()->send
         (gr_vector_const_void_star(_nchan), 0, _metadata,
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index e174e11..eeb9521 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -348,7 +348,8 @@ namespace gr {
     {
       _update_stream_args(stream_args);
 #ifdef GR_UHD_USE_STREAM_API
-      _rx_stream.reset();
+      if(_rx_stream)
+        _rx_stream.reset();
 #else
       throw std::runtime_error("not implemented in this version");
 #endif
@@ -409,7 +410,12 @@ namespace gr {
       while(true) {
 #ifdef GR_UHD_USE_STREAM_API
         const size_t bpi = 
::uhd::convert::get_bytes_per_item(_stream_args.cpu_format);
-        _rx_stream->recv(outputs, nbytes/bpi, _metadata, 0.0);
+        if(_rx_stream)
+          // get the remaining samples out of the buffers
+          _rx_stream->recv(outputs, nbytes/bpi, _metadata, 0.0);
+        else
+          // no rx streamer -- nothing to flush
+          break; 
 #else
         _dev->get_device()->recv
           (outputs, nbytes/_type->size, _metadata, *_type,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]