+ int num_bytes = num_iso_pack * size;
+ assert(size_t(num_bytes) <= buf_size);
+#if LIBUSB_API_VERSION >= 0x01000105
+ uint8_t *buf = libusb_dev_mem_alloc(devh, num_bytes);
+#else
+ uint8_t *buf = nullptr;
+#endif
+ if (buf == nullptr) {
+ fprintf(stderr, "Failed to allocate persistent DMA memory ");
+#if LIBUSB_API_VERSION >= 0x01000105
+ fprintf(stderr, "(probably too old kernel; use 4.6.0 or newer).\n");
+#else
+ fprintf(stderr, "(compiled against too old libusb-1.0).\n");
+#endif
+ fprintf(stderr, "Will go slower, and likely fail due to memory fragmentation after a few hours.\n");
+ buf = new uint8_t[num_bytes];
+ }