-#ifdef _WIN32
- /* Create events used to signal between main and USB wait threads. */
- ctx->usb_wait_request_event = CreateEvent(NULL, TRUE, FALSE, NULL);
- ctx->usb_wait_complete_event = CreateEvent(NULL, TRUE, FALSE, NULL);
- /* Start USB wait thread. */
- ctx->usb_thread_running = TRUE;
- ctx->usb_thread = g_thread_new("usb", usb_thread, ctx);
- /* Add event, set by USB wait thread, to session poll set. */
- ctx->usb_pollfd.fd = ctx->usb_wait_complete_event;
- ctx->usb_pollfd.events = G_IO_IN;
- ctx->usb_pollfd.revents = 0;
- ctx->usb_cb = cb;
- ctx->usb_cb_data = cb_data;
- sr_session_source_add_pollfd(session, &ctx->usb_pollfd, timeout,
- usb_callback, ctx);
+ for (i = 0; ret == SR_OK && pollfds[i]; ++i) {
+#ifdef G_OS_WIN32
+ events = G_IO_IN;
+#else
+ events = pollfds[i]->events;
+#endif
+ ret = sr_session_source_poll_add(session, tag,
+ (gintptr)pollfds[i]->fd, events);
+ }
+#if (LIBUSB_API_VERSION >= 0x01000104)
+ libusb_free_pollfds(pollfds);