-#ifdef G_OS_WIN32
-/*
- * USB callback wrapper run when the main loop is idle.
- */
-static int usb_callback(int fd, int revents, void *cb_data)
-{
- int64_t start_time, stop_time, due, timeout;
- struct timeval tv;
- struct sr_context *ctx;
- int ret;
-
- (void)fd;
- (void)revents;
- ctx = cb_data;
-
- start_time = g_get_monotonic_time();
- due = ctx->usb_due;
-
- if (due > start_time) {
- timeout = due - start_time;
- tv.tv_sec = timeout / G_USEC_PER_SEC;
- tv.tv_usec = timeout % G_USEC_PER_SEC;
-
- sr_spew("libusb_handle_events enter: %g ms timeout",
- 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));
- /*
- * The event source may have been removed by the driver's
- * libusb transfer callback. Skip the callback in that case.
- */
- if (!ctx->usb_source_present)
- return TRUE;
- } else {
- /* Timeout already expired on entry.
- */
- stop_time = start_time;
-
- sr_spew("libusb_handle_events skipped");
- }
-
- if (ctx->usb_timeout >= 0)
- ctx->usb_due = stop_time + ctx->usb_timeout;
- /*
- * Run the registered callback to execute any follow-up activity
- * to libusb's event handling.
- */
- return ctx->usb_cb(-1, (stop_time < due) ? G_IO_IN : 0,
- ctx->usb_cb_data);
-}
-#endif
-