From 3d3888c40ac46cbbd8851e9bc5e83557e0415887 Mon Sep 17 00:00:00 2001 From: ttsou Date: Tue, 25 Aug 2009 18:46:14 -0400 Subject: [PATCH] non-blocking reap and fusb default buffer size change --- usrp/host/lib/fusb_libusb1.cc | 17 +++++++++++------ usrp/host/lib/fusb_sysconfig_libusb1.cc | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/usrp/host/lib/fusb_libusb1.cc b/usrp/host/lib/fusb_libusb1.cc index 0559022b..6f1fc913 100644 --- a/usrp/host/lib/fusb_libusb1.cc +++ b/usrp/host/lib/fusb_libusb1.cc @@ -268,8 +268,18 @@ bool fusb_devhandle_libusb1::_reap (bool ok_to_block_p) { int ret; + struct timeval tv; - if ((ret = libusb_handle_events(d_ctx)) < 0) { + if (ok_to_block_p) { + tv.tv_sec = 2; + tv.tv_usec = 0; + } + else { + tv.tv_sec = 0; + tv.tv_usec = 0; + } + + if ((ret = libusb_handle_events_timeout(d_ctx, &tv)) < 0) { fprintf (stderr, "fusb::_reap libusb_handle_events()\n"); return false; } @@ -281,11 +291,6 @@ void fusb_devhandle_libusb1::_wait_for_completion () { - int ret; - struct timeval tv; - tv.tv_sec = 1; - tv.tv_usec = 0; - while (!d_pending_rqsts.empty ()) if (!_reap(true)) break; diff --git a/usrp/host/lib/fusb_sysconfig_libusb1.cc b/usrp/host/lib/fusb_sysconfig_libusb1.cc index c82bfe9a..a005f540 100644 --- a/usrp/host/lib/fusb_sysconfig_libusb1.cc +++ b/usrp/host/lib/fusb_sysconfig_libusb1.cc @@ -25,7 +25,7 @@ static const int MAX_BLOCK_SIZE = 16 * 1024; // hard limit static const int DEFAULT_BLOCK_SIZE = 4 * 1024; -static const int FUSB_BUFFER_SIZE = 2 * (1L << 20); // 2 MB +static const int FUSB_BUFFER_SIZE = 1 * (1L << 20); // 1 MB struct libusb_context; -- 2.39.5