+ sr_spew("libusb_handle_events enter, timeout %g ms", 1e-3 * timeout);
+
+ ret = libusb_handle_events_timeout_completed(ctx->libusb_ctx,
+ (ctx->usb_timeout < 0) ? NULL : &tv, NULL);
+ if (ret != 0) {
+ /* Warn but still invoke the callback, to give the driver
+ * a chance to deal with the problem.
+ */
+ sr_warn("Error handling libusb event (%s)",
+ libusb_error_name(ret));
+ }
+ stop_time = g_get_monotonic_time();
+
+ sr_spew("libusb_handle_events leave, %g ms elapsed",
+ 1e-3 * (stop_time - start_time));
+
+ if (ctx->usb_timeout >= 0)
+ ctx->usb_due = stop_time + ctx->usb_timeout;
+ /*
+ * Run registered callback to execute any follow-up activity
+ * to libusb event handling.
+ */
+ return ctx->usb_cb(-1, (stop_time < due) ? G_IO_IN : 0,
+ ctx->usb_cb_data);