diff options
-rw-r--r-- | gr-uhd/lib/usrp_source_impl.cc | 10 | ||||
-rw-r--r-- | gr-uhd/lib/usrp_source_impl.h | 5 |
2 files changed, 11 insertions, 4 deletions
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc index 318bdb627d..e57db13a0b 100644 --- a/gr-uhd/lib/usrp_source_impl.cc +++ b/gr-uhd/lib/usrp_source_impl.cc @@ -491,9 +491,12 @@ namespace gr { bool usrp_source_impl::start(void) { + boost::recursive_mutex::scoped_lock lock(d_mutex); #ifdef GR_UHD_USE_STREAM_API - _rx_stream = _dev->get_rx_stream(_stream_args); - _samps_per_packet = _rx_stream->get_max_num_samps(); + if(not _rx_stream){ + _rx_stream = _dev->get_rx_stream(_stream_args); + _samps_per_packet = _rx_stream->get_max_num_samps(); + } #endif //setup a stream command that starts streaming slightly in the future static const double reasonable_delay = 0.1; //order of magnitude over RTT @@ -537,8 +540,8 @@ namespace gr { bool usrp_source_impl::stop(void) { + boost::recursive_mutex::scoped_lock lock(d_mutex); this->issue_stream_cmd(::uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS); - this->flush(); return true; @@ -603,6 +606,7 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { + boost::recursive_mutex::scoped_lock lock(d_mutex); #ifdef GR_UHD_USE_STREAM_API //In order to allow for low-latency: //We receive all available packets without timeout. diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h index 58bb21551c..3cfa1aad35 100644 --- a/gr-uhd/lib/usrp_source_impl.h +++ b/gr-uhd/lib/usrp_source_impl.h @@ -22,6 +22,7 @@ #include <gnuradio/uhd/usrp_source.h> #include <uhd/convert.hpp> +#include <boost/thread/mutex.hpp> static const pmt::pmt_t TIME_KEY = pmt::string_to_symbol("rx_time"); static const pmt::pmt_t RATE_KEY = pmt::string_to_symbol("rx_rate"); @@ -121,7 +122,7 @@ namespace gr { int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - + private: ::uhd::usrp::multi_usrp::sptr _dev; const ::uhd::stream_args_t _stream_args; @@ -142,6 +143,8 @@ namespace gr { //tag shadows double _samp_rate; double _center_freq; + + boost::recursive_mutex d_mutex; }; } /* namespace uhd */ |