summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
authorJohnathan Corgan2012-06-02 05:59:29 -0700
committerJohnathan Corgan2012-06-02 05:59:29 -0700
commitb7e2c8ba2cba5014fa2de28dc48d742b943406b3 (patch)
treebfb8ab9cbadd2d5a00781056f6c6d289773c3e90 /gr-uhd
parent8569580b4ef8c1eccf5bdb81af60787e5b6bb8e9 (diff)
parentc78d307ecd5dac4e28190e5aa9b8377538f65ffa (diff)
downloadgnuradio-b7e2c8ba2cba5014fa2de28dc48d742b943406b3.tar.gz
gnuradio-b7e2c8ba2cba5014fa2de28dc48d742b943406b3.tar.bz2
gnuradio-b7e2c8ba2cba5014fa2de28dc48d742b943406b3.zip
Merge remote-tracking branch 'jblum/wip_uhd_stopper'
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_source.cc22
1 files changed, 21 insertions, 1 deletions
diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc
index 8aa965401..99deb70c7 100644
--- a/gr-uhd/lib/gr_uhd_usrp_source.cc
+++ b/gr-uhd/lib/gr_uhd_usrp_source.cc
@@ -24,6 +24,8 @@
#include <stdexcept>
#include <iostream>
#include <boost/format.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition_variable.hpp>
#include <boost/make_shared.hpp>
#include "gr_uhd_common.h"
@@ -60,7 +62,8 @@ public:
_nchan(std::max<size_t>(1, stream_args.channels.size())),
_stream_now(_nchan == 1),
_tag_now(false),
- _start_time_set(false)
+ _start_time_set(false),
+ _is_streaming(false)
{
if (stream_args.cpu_format == "fc32") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_FLOAT32);
if (stream_args.cpu_format == "sc16") _type = boost::make_shared<uhd::io_type_t>(uhd::io_type_t::COMPLEX_INT16);
@@ -320,6 +323,13 @@ public:
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items
){
+ boost::mutex::scoped_lock lock(_mutex);
+
+ while (!_is_streaming)
+ {
+ _cond.wait(lock);
+ }
+
#ifdef GR_UHD_USE_STREAM_API
//In order to allow for low-latency:
//We receive all available packets without timeout.
@@ -392,6 +402,9 @@ public:
}
bool start(void){
+ boost::mutex::scoped_lock lock(_mutex);
+ _is_streaming = true;
+
#ifdef GR_UHD_USE_STREAM_API
_rx_stream = _dev->get_rx_stream(_stream_args);
_samps_per_packet = _rx_stream->get_max_num_samps();
@@ -436,6 +449,9 @@ public:
}
bool stop(void){
+ boost::mutex::scoped_lock lock(_mutex);
+ _is_streaming = false;
+
_dev->issue_stream_cmd(uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS);
this->flush();
@@ -508,6 +524,10 @@ private:
uhd::time_spec_t _start_time;
bool _start_time_set;
+
+ bool _is_streaming;
+ boost::condition_variable _cond;
+ boost::mutex _mutex;
};