aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/transport/libusb1_zero_copy.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-08-27 16:59:24 -0700
committerJosh Blum <josh@joshknows.com>2010-08-27 16:59:24 -0700
commit39629ec4aa1b8409b0c5470ebe51d92589b5957e (patch)
tree79c2c7e3a7c1d05da112af9a18f683d0c07cf987 /host/lib/transport/libusb1_zero_copy.cpp
parentaa2ef7d246e93f4e6c0cb8b9b985a487cd2ea548 (diff)
parentec8005e3d5d1a80f89f5cfbaa8e1cdadf2d14db6 (diff)
downloaduhd-39629ec4aa1b8409b0c5470ebe51d92589b5957e.tar.gz
uhd-39629ec4aa1b8409b0c5470ebe51d92589b5957e.tar.bz2
uhd-39629ec4aa1b8409b0c5470ebe51d92589b5957e.zip
Merge branch 'usrp1' of ettus.sourcerepo.com:ettus/uhdpriv into usrp1
Diffstat (limited to 'host/lib/transport/libusb1_zero_copy.cpp')
-rw-r--r--host/lib/transport/libusb1_zero_copy.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp
index 55aa10cbb..4469991b8 100644
--- a/host/lib/transport/libusb1_zero_copy.cpp
+++ b/host/lib/transport/libusb1_zero_copy.cpp
@@ -25,7 +25,7 @@
using namespace uhd::transport;
-const int libusb_debug_level = 3;
+const int libusb_debug_level = 0;
const int libusb_timeout = 0;
/***********************************************************************
@@ -555,7 +555,7 @@ public:
libusb_managed_send_buffer_impl(libusb_transfer *lut,
usb_endpoint *endpoint,
size_t buff_size)
- : _buff(lut->buffer, buff_size)
+ : _buff(lut->buffer, buff_size), _committed(false)
{
_lut = lut;
_endpoint = endpoint;
@@ -563,18 +563,32 @@ public:
~libusb_managed_send_buffer_impl()
{
- /* NOP */
+ if (!_committed) {
+ _lut->length = 0;
+ _lut->actual_length = 0;
+ _endpoint->submit(_lut);
+ }
}
ssize_t commit(size_t num_bytes)
{
+ if (_committed) {
+ std::cerr << "UHD: send buffer already committed" << std::endl;
+ return 0;
+ }
+
+ UHD_ASSERT_THROW(num_bytes <= boost::asio::buffer_size(_buff));
+
_lut->length = num_bytes;
_lut->actual_length = 0;
- if (_endpoint->submit(_lut))
+ if (_endpoint->submit(_lut)) {
+ _committed = true;
return num_bytes;
- else
+ }
+ else {
return 0;
+ }
}
private:
@@ -586,6 +600,7 @@ private:
libusb_transfer *_lut;
usb_endpoint *_endpoint;
const boost::asio::mutable_buffer _buff;
+ bool _committed;
};