diff options
author | Michael West <michael.west@ettus.com> | 2013-11-19 11:16:44 -0800 |
---|---|---|
committer | Michael West <michael.west@ettus.com> | 2013-11-19 11:16:44 -0800 |
commit | 39d69b3a8871e4d6f442511e57394f83a012d3b6 (patch) | |
tree | b4c3f4f9dfcdf8f3e723141ee233bd62f19b0b33 /host/lib | |
parent | 7961fc2388211ea2edf8313ef729408acc700dd1 (diff) | |
download | uhd-39d69b3a8871e4d6f442511e57394f83a012d3b6.tar.gz uhd-39d69b3a8871e4d6f442511e57394f83a012d3b6.tar.bz2 uhd-39d69b3a8871e4d6f442511e57394f83a012d3b6.zip |
BUG #183: Addressed comments from code review.
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/transport/libusb1_zero_copy.cpp | 29 | ||||
-rw-r--r-- | host/lib/usrp/b200/b200_io_impl.cpp | 2 |
2 files changed, 16 insertions, 15 deletions
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index d269eef68..2d18e1623 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -74,12 +74,13 @@ struct lut_result_t libusb_transfer_status status; int actual_length; boost::mutex mut; - boost::condition_variable wait_for_complete; + boost::condition_variable usb_transfer_complete; }; +// Created to be used as an argument to boost::condition_variable::timed_wait() function struct lut_result_completed { - lut_result_t& _result; - lut_result_completed(lut_result_t& result):_result(result) {} + const lut_result_t& _result; + lut_result_completed(const lut_result_t& result):_result(result) {} bool operator()() const {return (_result.completed ? true : false);} }; @@ -96,7 +97,7 @@ static void LIBUSB_CALL libusb_async_cb(libusb_transfer *lut) r->status = lut->status; r->actual_length = lut->actual_length; r->completed = 1; - r->wait_for_complete.notify_one(); + r->usb_transfer_complete.notify_one(); // wake up thread waiting in wait_for_completion() member function below } /*********************************************************************** @@ -135,30 +136,30 @@ public: return typename buffer_type::sptr(); } - UHD_INLINE bool flush(double timeout) - { - return wait_for_completion(timeout); - } - + // This is public because it is accessed from the libusb_zero_copy_single constructor lut_result_t result; -private: /*! * Wait for a managed buffer to become complete. * - * \param timeout the wait timeout in seconds + * \param timeout the wait timeout in seconds. A negative value will wait forever. * \return true for completion, false for timeout */ UHD_INLINE bool wait_for_completion(const double timeout) { boost::unique_lock<boost::mutex> lock(result.mut); if (!result.completed) { - const boost::system_time timeout_time = boost::get_system_time() + boost::posix_time::microseconds(long(timeout*1000000)); - result.wait_for_complete.timed_wait(lock, timeout_time, lut_result_completed(result)); + if (timeout < 0.0) { + result.usb_transfer_complete.wait(lock); + } else { + const boost::system_time timeout_time = boost::get_system_time() + boost::posix_time::microseconds(long(timeout*1000000)); + result.usb_transfer_complete.timed_wait(lock, timeout_time, lut_result_completed(result)); + } } return result.completed; } +private: boost::function<void(libusb_zero_copy_mb *)> _release_cb; const bool _is_recv; @@ -254,7 +255,7 @@ public: //process all transfers until timeout occurs BOOST_FOREACH(libusb_zero_copy_mb *mb, _enqueued) { - mb->flush(0.01); + mb->wait_for_completion(0.01); } //free all transfers diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index f2d463a79..1feeff1a3 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -238,7 +238,7 @@ rx_streamer::sptr b200_impl::get_rx_stream(const uhd::stream_args_t &args_) const size_t bpp = _data_transport->get_recv_frame_size() - hdr_size; const size_t bpi = convert::get_bytes_per_item(args.otw_format); size_t spp = unsigned(args.args.cast<double>("spp", bpp/bpi)); - spp = std::min<size_t>(4092, spp); //magic maximum for framing at full rate + spp = std::min<size_t>(2044, spp); //magic maximum for framing at full rate //make the new streamer given the samples per packet if (not my_streamer) my_streamer = boost::make_shared<sph::recv_packet_streamer>(spp); |