summaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2012-08-04 14:02:09 -0400
committerJosh Blum <josh@joshknows.com>2012-08-04 14:22:09 -0400
commitd18fc6f0f1fe934cd8684171d966561a36fb134c (patch)
treec5275daad1dc32fe051ff53c7d53d9d46a6e8b94 /host/lib/transport
parenta38e440b53a0863fd0b50925c19ea4ef77e332db (diff)
downloaduhd-d18fc6f0f1fe934cd8684171d966561a36fb134c.tar.gz
uhd-d18fc6f0f1fe934cd8684171d966561a36fb134c.tar.bz2
uhd-d18fc6f0f1fe934cd8684171d966561a36fb134c.zip
usb: added recv buffer flushing to libusb zero copy
Diffstat (limited to 'host/lib/transport')
-rw-r--r--host/lib/transport/libusb1_zero_copy.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp
index c13384eec..28bff9709 100644
--- a/host/lib/transport/libusb1_zero_copy.cpp
+++ b/host/lib/transport/libusb1_zero_copy.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010-2011 Ettus Research LLC
+// Copyright 2010-2012 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -177,6 +177,23 @@ public:
_handle->claim_interface(recv_interface);
_handle->claim_interface(send_interface);
+ //flush the buffers out of the recv endpoint
+ //limit the flushing to at most one second
+ for (size_t i = 0; i < 100; i++)
+ {
+ unsigned char buff[512];
+ int transfered = 0;
+ const int status = libusb_bulk_transfer(
+ _handle->get(), // dev_handle
+ (recv_endpoint & 0x7f) | 0x80, // endpoint
+ static_cast<unsigned char *>(buff),
+ sizeof(buff),
+ &transfered, //bytes xfered
+ 10 //timeout ms
+ );
+ if (status == LIBUSB_ERROR_TIMEOUT) break;
+ }
+
//allocate libusb transfer structs and managed receive buffers
for (size_t i = 0; i < get_num_recv_frames(); i++){