libusb 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/.travis.yml +3 -3
  5. data/History.md +8 -0
  6. data/README.md +1 -0
  7. data/Rakefile +14 -14
  8. data/ext/{libusb-1.0.18 → libusb-1.0.19}/AUTHORS +6 -0
  9. data/ext/{libusb-1.0.18 → libusb-1.0.19}/COPYING +0 -0
  10. data/ext/{libusb-1.0.18 → libusb-1.0.19}/ChangeLog +9 -2
  11. data/ext/{libusb-1.0.18 → libusb-1.0.19}/INSTALL +0 -0
  12. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Makefile.am +0 -0
  13. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Makefile.in +188 -156
  14. data/ext/{libusb-1.0.18 → libusb-1.0.19}/NEWS +0 -0
  15. data/ext/{libusb-1.0.18 → libusb-1.0.19}/PORTING +0 -0
  16. data/ext/{libusb-1.0.18 → libusb-1.0.19}/README +0 -0
  17. data/ext/{libusb-1.0.18 → libusb-1.0.19}/TODO +0 -0
  18. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Xcode/common.xcconfig +10 -1
  19. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Xcode/config.h +0 -0
  20. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Xcode/debug.xcconfig +0 -0
  21. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Xcode/libusb.xcconfig +1 -1
  22. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Xcode/libusb.xcodeproj/project.pbxproj +0 -0
  23. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Xcode/libusb_debug.xcconfig +0 -0
  24. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Xcode/libusb_release.xcconfig +0 -0
  25. data/ext/{libusb-1.0.18 → libusb-1.0.19}/Xcode/release.xcconfig +1 -0
  26. data/ext/libusb-1.0.19/aclocal.m4 +1190 -0
  27. data/ext/{libusb-1.0.18 → libusb-1.0.19}/android/README +0 -0
  28. data/ext/{libusb-1.0.18 → libusb-1.0.19}/android/config.h +0 -0
  29. data/ext/{libusb-1.0.18 → libusb-1.0.19}/android/jni/Android.mk +0 -0
  30. data/ext/{libusb-1.0.18 → libusb-1.0.19}/android/jni/Application.mk +0 -0
  31. data/ext/{libusb-1.0.18 → libusb-1.0.19}/android/jni/examples.mk +0 -0
  32. data/ext/{libusb-1.0.18 → libusb-1.0.19}/android/jni/libusb.mk +0 -0
  33. data/ext/{libusb-1.0.18 → libusb-1.0.19}/android/jni/tests.mk +0 -0
  34. data/ext/{libusb-1.0.18 → libusb-1.0.19}/compile +7 -3
  35. data/ext/{libusb-1.0.18 → libusb-1.0.19}/config.guess +116 -78
  36. data/ext/{libusb-1.0.18 → libusb-1.0.19}/config.h.in +0 -3
  37. data/ext/{libusb-1.0.18 → libusb-1.0.19}/config.sub +66 -46
  38. data/ext/{libusb-1.0.18 → libusb-1.0.19}/configure +265 -208
  39. data/ext/{libusb-1.0.18 → libusb-1.0.19}/configure.ac +0 -0
  40. data/ext/{libusb-1.0.18 → libusb-1.0.19}/depcomp +269 -186
  41. data/ext/{libusb-1.0.18 → libusb-1.0.19}/doc/Makefile.am +0 -0
  42. data/ext/{libusb-1.0.18 → libusb-1.0.19}/doc/Makefile.in +72 -35
  43. data/ext/{libusb-1.0.18 → libusb-1.0.19}/doc/doxygen.cfg.in +1 -1
  44. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/Makefile.am +0 -0
  45. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/Makefile.in +134 -70
  46. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/dpfp.c +0 -0
  47. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/dpfp_threaded.c +0 -0
  48. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/ezusb.c +9 -5
  49. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/ezusb.h +0 -0
  50. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/fxload.c +1 -1
  51. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/getopt/getopt.c +0 -0
  52. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/getopt/getopt.h +0 -0
  53. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/getopt/getopt1.c +0 -0
  54. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/hotplugtest.c +0 -0
  55. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/listdevs.c +0 -0
  56. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/sam3u_benchmark.c +0 -0
  57. data/ext/{libusb-1.0.18 → libusb-1.0.19}/examples/xusb.c +22 -2
  58. data/ext/{libusb-1.0.18 → libusb-1.0.19}/install-sh +7 -7
  59. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb-1.0.pc.in +0 -0
  60. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/Makefile.am +0 -0
  61. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/Makefile.in +133 -93
  62. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/core.c +86 -15
  63. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/descriptor.c +0 -0
  64. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/hotplug.c +6 -1
  65. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/hotplug.h +0 -0
  66. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/io.c +54 -17
  67. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/libusb-1.0.def +8 -0
  68. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/libusb-1.0.rc +0 -0
  69. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/libusb.h +42 -2
  70. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/libusbi.h +10 -1
  71. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/darwin_usb.c +156 -53
  72. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/darwin_usb.h +1 -1
  73. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/linux_netlink.c +26 -2
  74. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/linux_udev.c +2 -1
  75. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/linux_usbfs.c +93 -6
  76. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/linux_usbfs.h +12 -1
  77. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/netbsd_usb.c +6 -0
  78. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/openbsd_usb.c +6 -0
  79. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/poll_posix.c +0 -0
  80. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/poll_posix.h +0 -0
  81. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/poll_windows.c +0 -0
  82. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/poll_windows.h +12 -6
  83. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/threads_posix.c +0 -0
  84. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/threads_posix.h +0 -0
  85. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/threads_windows.c +0 -0
  86. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/threads_windows.h +0 -0
  87. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/wince_usb.c +8 -1
  88. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/wince_usb.h +0 -0
  89. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/windows_common.h +0 -0
  90. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/windows_usb.c +175 -42
  91. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/os/windows_usb.h +35 -0
  92. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/strerror.c +17 -2
  93. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/sync.c +0 -0
  94. data/ext/{libusb-1.0.18 → libusb-1.0.19}/libusb/version.h +1 -1
  95. data/ext/libusb-1.0.19/libusb/version_nano.h +1 -0
  96. data/ext/{libusb-1.0.18 → libusb-1.0.19}/ltmain.sh +3 -3
  97. data/ext/{libusb-1.0.18/aclocal.m4 → libusb-1.0.19/m4/libtool.m4} +36 -1734
  98. data/ext/libusb-1.0.19/m4/ltoptions.m4 +384 -0
  99. data/ext/libusb-1.0.19/m4/ltsugar.m4 +123 -0
  100. data/ext/libusb-1.0.19/m4/ltversion.m4 +23 -0
  101. data/ext/libusb-1.0.19/m4/lt~obsolete.m4 +98 -0
  102. data/ext/libusb-1.0.19/missing +215 -0
  103. data/ext/{libusb-1.0.18 → libusb-1.0.19}/tests/Makefile.am +0 -0
  104. data/ext/{libusb-1.0.18 → libusb-1.0.19}/tests/Makefile.in +128 -70
  105. data/ext/{libusb-1.0.18 → libusb-1.0.19}/tests/libusb_testlib.h +0 -0
  106. data/ext/{libusb-1.0.18 → libusb-1.0.19}/tests/stress.c +0 -0
  107. data/ext/{libusb-1.0.18 → libusb-1.0.19}/tests/testlib.c +0 -0
  108. data/lib/libusb.rb +3 -1
  109. data/lib/libusb/bos.rb +306 -0
  110. data/lib/libusb/call.rb +84 -0
  111. data/lib/libusb/constants.rb +4 -0
  112. data/lib/libusb/dev_handle.rb +77 -0
  113. data/lib/libusb/endpoint.rb +20 -0
  114. data/lib/libusb/ss_companion.rb +69 -0
  115. data/lib/libusb/transfer.rb +34 -0
  116. data/lib/libusb/version_gem.rb +1 -1
  117. data/libusb.gemspec +1 -0
  118. data/test/test_libusb_bos.rb +118 -0
  119. data/test/test_libusb_bulk_stream_transfer.rb +50 -0
  120. data/test/test_libusb_descriptors.rb +29 -0
  121. data/test/test_libusb_hotplug.rb +1 -1
  122. data/test/test_libusb_threads.rb +1 -1
  123. metadata +146 -124
  124. metadata.gz.sig +0 -0
  125. data/ext/libusb-1.0.18/libusb/version_nano.h +0 -1
  126. data/ext/libusb-1.0.18/missing +0 -331
@@ -775,22 +775,22 @@ int API_EXPORTED libusb_get_port_numbers(libusb_device *dev,
775
775
  uint8_t* port_numbers, int port_numbers_len)
776
776
  {
777
777
  int i = port_numbers_len;
778
+ struct libusb_context *ctx = DEVICE_CTX(dev);
778
779
 
779
- while(dev) {
780
- // HCDs can be listed as devices and would have port #0
781
- // TODO: see how the other backends want to implement HCDs as parents
782
- if (dev->port_number == 0)
783
- break;
784
- i--;
785
- if (i < 0) {
786
- usbi_warn(DEVICE_CTX(dev),
787
- "port numbers array too small");
780
+ if (port_numbers_len <= 0)
781
+ return LIBUSB_ERROR_INVALID_PARAM;
782
+
783
+ // HCDs can be listed as devices with port #0
784
+ while((dev) && (dev->port_number != 0)) {
785
+ if (--i < 0) {
786
+ usbi_warn(ctx, "port numbers array is too small");
788
787
  return LIBUSB_ERROR_OVERFLOW;
789
788
  }
790
789
  port_numbers[i] = dev->port_number;
791
790
  dev = dev->parent_dev;
792
791
  }
793
- memmove(port_numbers, &port_numbers[i], port_numbers_len - i);
792
+ if (i < port_numbers_len)
793
+ memmove(port_numbers, &port_numbers[i], port_numbers_len - i);
794
794
  return port_numbers_len - i;
795
795
  }
796
796
 
@@ -899,10 +899,14 @@ int API_EXPORTED libusb_get_max_packet_size(libusb_device *dev,
899
899
  }
900
900
 
901
901
  ep = find_endpoint(config, endpoint);
902
- if (!ep)
903
- return LIBUSB_ERROR_NOT_FOUND;
902
+ if (!ep) {
903
+ r = LIBUSB_ERROR_NOT_FOUND;
904
+ goto out;
905
+ }
904
906
 
905
907
  r = ep->wMaxPacketSize;
908
+
909
+ out:
906
910
  libusb_free_config_descriptor(config);
907
911
  return r;
908
912
  }
@@ -950,17 +954,21 @@ int API_EXPORTED libusb_get_max_iso_packet_size(libusb_device *dev,
950
954
  }
951
955
 
952
956
  ep = find_endpoint(config, endpoint);
953
- if (!ep)
954
- return LIBUSB_ERROR_NOT_FOUND;
957
+ if (!ep) {
958
+ r = LIBUSB_ERROR_NOT_FOUND;
959
+ goto out;
960
+ }
955
961
 
956
962
  val = ep->wMaxPacketSize;
957
963
  ep_type = (enum libusb_transfer_type) (ep->bmAttributes & 0x3);
958
- libusb_free_config_descriptor(config);
959
964
 
960
965
  r = val & 0x07ff;
961
966
  if (ep_type == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS
962
967
  || ep_type == LIBUSB_TRANSFER_TYPE_INTERRUPT)
963
968
  r *= (1 + ((val >> 11) & 3));
969
+
970
+ out:
971
+ libusb_free_config_descriptor(config);
964
972
  return r;
965
973
  }
966
974
 
@@ -1615,6 +1623,69 @@ int API_EXPORTED libusb_reset_device(libusb_device_handle *dev)
1615
1623
  return usbi_backend->reset_device(dev);
1616
1624
  }
1617
1625
 
1626
+ /** \ingroup asyncio
1627
+ * Allocate up to num_streams usb bulk streams on the specified endpoints. This
1628
+ * function takes an array of endpoints rather then a single endpoint because
1629
+ * some protocols require that endpoints are setup with similar stream ids.
1630
+ * All endpoints passed in must belong to the same interface.
1631
+ *
1632
+ * Note this function may return less streams then requested. Also note that the
1633
+ * same number of streams are allocated for each endpoint in the endpoint array.
1634
+ *
1635
+ * Stream id 0 is reserved, and should not be used to communicate with devices.
1636
+ * If libusb_alloc_streams() returns with a value of N, you may use stream ids
1637
+ * 1 to N.
1638
+ *
1639
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
1640
+ *
1641
+ * \param dev a device handle
1642
+ * \param num_streams number of streams to try to allocate
1643
+ * \param endpoints array of endpoints to allocate streams on
1644
+ * \param num_endpoints length of the endpoints array
1645
+ * \returns number of streams allocated, or a LIBUSB_ERROR code on failure
1646
+ */
1647
+ int API_EXPORTED libusb_alloc_streams(libusb_device_handle *dev,
1648
+ uint32_t num_streams, unsigned char *endpoints, int num_endpoints)
1649
+ {
1650
+ usbi_dbg("streams %u eps %d", (unsigned) num_streams, num_endpoints);
1651
+
1652
+ if (!dev->dev->attached)
1653
+ return LIBUSB_ERROR_NO_DEVICE;
1654
+
1655
+ if (usbi_backend->alloc_streams)
1656
+ return usbi_backend->alloc_streams(dev, num_streams, endpoints,
1657
+ num_endpoints);
1658
+ else
1659
+ return LIBUSB_ERROR_NOT_SUPPORTED;
1660
+ }
1661
+
1662
+ /** \ingroup asyncio
1663
+ * Free usb bulk streams allocated with libusb_alloc_streams().
1664
+ *
1665
+ * Note streams are automatically free-ed when releasing an interface.
1666
+ *
1667
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
1668
+ *
1669
+ * \param dev a device handle
1670
+ * \param endpoints array of endpoints to free streams on
1671
+ * \param num_endpoints length of the endpoints array
1672
+ * \returns LIBUSB_SUCCESS, or a LIBUSB_ERROR code on failure
1673
+ */
1674
+ int API_EXPORTED libusb_free_streams(libusb_device_handle *dev,
1675
+ unsigned char *endpoints, int num_endpoints)
1676
+ {
1677
+ usbi_dbg("eps %d", num_endpoints);
1678
+
1679
+ if (!dev->dev->attached)
1680
+ return LIBUSB_ERROR_NO_DEVICE;
1681
+
1682
+ if (usbi_backend->free_streams)
1683
+ return usbi_backend->free_streams(dev, endpoints,
1684
+ num_endpoints);
1685
+ else
1686
+ return LIBUSB_ERROR_NOT_SUPPORTED;
1687
+ }
1688
+
1618
1689
  /** \ingroup dev
1619
1690
  * Determine if a kernel driver is active on an interface. If a kernel driver
1620
1691
  * is active, you cannot claim the interface, and libusb will be unable to
@@ -86,6 +86,10 @@
86
86
  *
87
87
  * The following code provides an example of the usage of the hotplug interface:
88
88
  \code
89
+ #include <stdio.h>
90
+ #include <stdlib.h>
91
+ #include <libusb.h>
92
+
89
93
  static int count = 0;
90
94
 
91
95
  int hotplug_callback(struct libusb_context *ctx, struct libusb_device *dev,
@@ -131,10 +135,11 @@ int main (void) {
131
135
  }
132
136
 
133
137
  while (count < 2) {
138
+ libusb_handle_events_completed(NULL, NULL);
134
139
  usleep(10000);
135
140
  }
136
141
 
137
- libusb_hotplug_deregister_callback(handle);
142
+ libusb_hotplug_deregister_callback(NULL, handle);
138
143
  libusb_exit(NULL);
139
144
 
140
145
  return 0;
@@ -1439,6 +1439,7 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
1439
1439
  int r;
1440
1440
  int updated_fds;
1441
1441
 
1442
+ usbi_mutex_lock(&ctx->flying_transfers_lock);
1442
1443
  usbi_mutex_lock(&itransfer->lock);
1443
1444
  itransfer->transferred = 0;
1444
1445
  itransfer->flags = 0;
@@ -1448,7 +1449,6 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
1448
1449
  goto out;
1449
1450
  }
1450
1451
 
1451
- usbi_mutex_lock(&ctx->flying_transfers_lock);
1452
1452
  r = add_to_flying_list(itransfer);
1453
1453
  if (r == LIBUSB_SUCCESS) {
1454
1454
  r = usbi_backend->submit_transfer(itransfer);
@@ -1456,14 +1456,14 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer)
1456
1456
  if (r != LIBUSB_SUCCESS) {
1457
1457
  list_del(&itransfer->list);
1458
1458
  arm_timerfd_for_next_timeout(ctx);
1459
+ } else {
1460
+ /* keep a reference to this device */
1461
+ libusb_ref_device(transfer->dev_handle->dev);
1459
1462
  }
1460
- usbi_mutex_unlock(&ctx->flying_transfers_lock);
1461
-
1462
- /* keep a reference to this device */
1463
- libusb_ref_device(transfer->dev_handle->dev);
1464
1463
  out:
1465
1464
  updated_fds = (itransfer->flags & USBI_TRANSFER_UPDATED_FDS);
1466
1465
  usbi_mutex_unlock(&itransfer->lock);
1466
+ usbi_mutex_unlock(&ctx->flying_transfers_lock);
1467
1467
  if (updated_fds)
1468
1468
  usbi_fd_notification(ctx);
1469
1469
  return r;
@@ -1510,6 +1510,43 @@ int API_EXPORTED libusb_cancel_transfer(struct libusb_transfer *transfer)
1510
1510
  return r;
1511
1511
  }
1512
1512
 
1513
+ /** \ingroup asyncio
1514
+ * Set a transfers bulk stream id. Note users are advised to use
1515
+ * libusb_fill_bulk_stream_transfer() instead of calling this function
1516
+ * directly.
1517
+ *
1518
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
1519
+ *
1520
+ * \param transfer the transfer to set the stream id for
1521
+ * \param stream_id the stream id to set
1522
+ * \see libusb_alloc_streams()
1523
+ */
1524
+ void API_EXPORTED libusb_transfer_set_stream_id(
1525
+ struct libusb_transfer *transfer, uint32_t stream_id)
1526
+ {
1527
+ struct usbi_transfer *itransfer =
1528
+ LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
1529
+
1530
+ itransfer->stream_id = stream_id;
1531
+ }
1532
+
1533
+ /** \ingroup asyncio
1534
+ * Get a transfers bulk stream id.
1535
+ *
1536
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
1537
+ *
1538
+ * \param transfer the transfer to get the stream id for
1539
+ * \returns the stream id for the transfer
1540
+ */
1541
+ uint32_t API_EXPORTED libusb_transfer_get_stream_id(
1542
+ struct libusb_transfer *transfer)
1543
+ {
1544
+ struct usbi_transfer *itransfer =
1545
+ LIBUSB_TRANSFER_TO_USBI_TRANSFER(transfer);
1546
+
1547
+ return itransfer->stream_id;
1548
+ }
1549
+
1513
1550
  /* Handle completion of a transfer (completion might be an error condition).
1514
1551
  * This will invoke the user-supplied callback function, which may end up
1515
1552
  * freeing the transfer. Therefore you cannot use the transfer structure
@@ -1604,7 +1641,7 @@ int usbi_handle_transfer_cancellation(struct usbi_transfer *transfer)
1604
1641
  * \param ctx the context to operate on, or NULL for the default context
1605
1642
  * \returns 0 if the lock was obtained successfully
1606
1643
  * \returns 1 if the lock was not obtained (i.e. another thread holds the lock)
1607
- * \see \ref mtasync
1644
+ * \ref mtasync
1608
1645
  */
1609
1646
  int API_EXPORTED libusb_try_lock_events(libusb_context *ctx)
1610
1647
  {
@@ -1646,7 +1683,7 @@ int API_EXPORTED libusb_try_lock_events(libusb_context *ctx)
1646
1683
  * as soon as possible.
1647
1684
  *
1648
1685
  * \param ctx the context to operate on, or NULL for the default context
1649
- * \see \ref mtasync
1686
+ * \ref mtasync
1650
1687
  */
1651
1688
  void API_EXPORTED libusb_lock_events(libusb_context *ctx)
1652
1689
  {
@@ -1661,7 +1698,7 @@ void API_EXPORTED libusb_lock_events(libusb_context *ctx)
1661
1698
  * on libusb_wait_for_event().
1662
1699
  *
1663
1700
  * \param ctx the context to operate on, or NULL for the default context
1664
- * \see \ref mtasync
1701
+ * \ref mtasync
1665
1702
  */
1666
1703
  void API_EXPORTED libusb_unlock_events(libusb_context *ctx)
1667
1704
  {
@@ -1696,7 +1733,7 @@ void API_EXPORTED libusb_unlock_events(libusb_context *ctx)
1696
1733
  * \param ctx the context to operate on, or NULL for the default context
1697
1734
  * \returns 1 if event handling can start or continue
1698
1735
  * \returns 0 if this thread must give up the events lock
1699
- * \see \ref fullstory "Multi-threaded I/O: the full story"
1736
+ * \ref fullstory "Multi-threaded I/O: the full story"
1700
1737
  */
1701
1738
  int API_EXPORTED libusb_event_handling_ok(libusb_context *ctx)
1702
1739
  {
@@ -1724,7 +1761,7 @@ int API_EXPORTED libusb_event_handling_ok(libusb_context *ctx)
1724
1761
  * \param ctx the context to operate on, or NULL for the default context
1725
1762
  * \returns 1 if a thread is handling events
1726
1763
  * \returns 0 if there are no threads currently handling events
1727
- * \see \ref mtasync
1764
+ * \ref mtasync
1728
1765
  */
1729
1766
  int API_EXPORTED libusb_event_handler_active(libusb_context *ctx)
1730
1767
  {
@@ -1761,7 +1798,7 @@ int API_EXPORTED libusb_event_handler_active(libusb_context *ctx)
1761
1798
  * locking.
1762
1799
  *
1763
1800
  * \param ctx the context to operate on, or NULL for the default context
1764
- * \see \ref mtasync
1801
+ * \ref mtasync
1765
1802
  */
1766
1803
  void API_EXPORTED libusb_lock_event_waiters(libusb_context *ctx)
1767
1804
  {
@@ -1772,7 +1809,7 @@ void API_EXPORTED libusb_lock_event_waiters(libusb_context *ctx)
1772
1809
  /** \ingroup poll
1773
1810
  * Release the event waiters lock.
1774
1811
  * \param ctx the context to operate on, or NULL for the default context
1775
- * \see \ref mtasync
1812
+ * \ref mtasync
1776
1813
  */
1777
1814
  void API_EXPORTED libusb_unlock_event_waiters(libusb_context *ctx)
1778
1815
  {
@@ -1803,7 +1840,7 @@ void API_EXPORTED libusb_unlock_event_waiters(libusb_context *ctx)
1803
1840
  * indicates unlimited timeout.
1804
1841
  * \returns 0 after a transfer completes or another thread stops event handling
1805
1842
  * \returns 1 if the timeout expired
1806
- * \see \ref mtasync
1843
+ * \ref mtasync
1807
1844
  */
1808
1845
  int API_EXPORTED libusb_wait_for_event(libusb_context *ctx, struct timeval *tv)
1809
1846
  {
@@ -2114,7 +2151,7 @@ static int get_next_timeout(libusb_context *ctx, struct timeval *tv,
2114
2151
  * timeval struct for non-blocking mode
2115
2152
  * \param completed pointer to completion integer to check, or NULL
2116
2153
  * \returns 0 on success, or a LIBUSB_ERROR code on failure
2117
- * \see \ref mtasync
2154
+ * \ref mtasync
2118
2155
  */
2119
2156
  int API_EXPORTED libusb_handle_events_timeout_completed(libusb_context *ctx,
2120
2157
  struct timeval *tv, int *completed)
@@ -2225,7 +2262,7 @@ int API_EXPORTED libusb_handle_events(libusb_context *ctx)
2225
2262
  * \param ctx the context to operate on, or NULL for the default context
2226
2263
  * \param completed pointer to completion integer to check, or NULL
2227
2264
  * \returns 0 on success, or a LIBUSB_ERROR code on failure
2228
- * \see \ref mtasync
2265
+ * \ref mtasync
2229
2266
  */
2230
2267
  int API_EXPORTED libusb_handle_events_completed(libusb_context *ctx,
2231
2268
  int *completed)
@@ -2251,7 +2288,7 @@ int API_EXPORTED libusb_handle_events_completed(libusb_context *ctx,
2251
2288
  * \param tv the maximum time to block waiting for events, or zero for
2252
2289
  * non-blocking mode
2253
2290
  * \returns 0 on success, or a LIBUSB_ERROR code on failure
2254
- * \see \ref mtasync
2291
+ * \ref mtasync
2255
2292
  */
2256
2293
  int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx,
2257
2294
  struct timeval *tv)
@@ -2295,7 +2332,7 @@ int API_EXPORTED libusb_handle_events_locked(libusb_context *ctx,
2295
2332
  * \returns 0 if you must call into libusb at times determined by
2296
2333
  * libusb_get_next_timeout(), or 1 if all timeout events are handled internally
2297
2334
  * or through regular activity on the file descriptors.
2298
- * \see \ref pollmain "Polling libusb file descriptors for event handling"
2335
+ * \ref pollmain "Polling libusb file descriptors for event handling"
2299
2336
  */
2300
2337
  int API_EXPORTED libusb_pollfds_handle_timeouts(libusb_context *ctx)
2301
2338
  {
@@ -1,5 +1,7 @@
1
1
  LIBRARY "libusb-1.0.dll"
2
2
  EXPORTS
3
+ libusb_alloc_streams
4
+ libusb_alloc_streams@16 = libusb_alloc_streams
3
5
  libusb_alloc_transfer
4
6
  libusb_alloc_transfer@4 = libusb_alloc_transfer
5
7
  libusb_attach_kernel_driver
@@ -38,6 +40,8 @@ EXPORTS
38
40
  libusb_free_ss_endpoint_companion_descriptor@4 = libusb_free_ss_endpoint_companion_descriptor
39
41
  libusb_free_ss_usb_device_capability_descriptor
40
42
  libusb_free_ss_usb_device_capability_descriptor@4 = libusb_free_ss_usb_device_capability_descriptor
43
+ libusb_free_streams
44
+ libusb_free_streams@12 = libusb_free_streams
41
45
  libusb_free_transfer
42
46
  libusb_free_transfer@4 = libusb_free_transfer
43
47
  libusb_free_usb_2_0_extension_descriptor
@@ -146,6 +150,10 @@ EXPORTS
146
150
  libusb_strerror@4 = libusb_strerror
147
151
  libusb_submit_transfer
148
152
  libusb_submit_transfer@4 = libusb_submit_transfer
153
+ libusb_transfer_get_stream_id
154
+ libusb_transfer_get_stream_id@4 = libusb_transfer_get_stream_id
155
+ libusb_transfer_set_stream_id
156
+ libusb_transfer_set_stream_id@8 = libusb_transfer_set_stream_id
149
157
  libusb_try_lock_events
150
158
  libusb_try_lock_events@4 = libusb_try_lock_events
151
159
  libusb_unlock_event_waiters
@@ -144,7 +144,7 @@ typedef unsigned __int32 uint32_t;
144
144
  * Internally, LIBUSB_API_VERSION is defined as follows:
145
145
  * (libusb major << 24) | (libusb minor << 16) | (16 bit incremental)
146
146
  */
147
- #define LIBUSB_API_VERSION 0x01000102
147
+ #define LIBUSB_API_VERSION 0x01000103
148
148
 
149
149
  /* The following is kept for compatibility, but will be deprecated in the future */
150
150
  #define LIBUSBX_API_VERSION LIBUSB_API_VERSION
@@ -343,7 +343,10 @@ enum libusb_transfer_type {
343
343
  LIBUSB_TRANSFER_TYPE_BULK = 2,
344
344
 
345
345
  /** Interrupt endpoint */
346
- LIBUSB_TRANSFER_TYPE_INTERRUPT = 3
346
+ LIBUSB_TRANSFER_TYPE_INTERRUPT = 3,
347
+
348
+ /** Stream endpoint */
349
+ LIBUSB_TRANSFER_TYPE_BULK_STREAM = 4,
347
350
  };
348
351
 
349
352
  /** \ingroup misc
@@ -1387,6 +1390,11 @@ int LIBUSB_CALL libusb_clear_halt(libusb_device_handle *dev,
1387
1390
  unsigned char endpoint);
1388
1391
  int LIBUSB_CALL libusb_reset_device(libusb_device_handle *dev);
1389
1392
 
1393
+ int LIBUSB_CALL libusb_alloc_streams(libusb_device_handle *dev,
1394
+ uint32_t num_streams, unsigned char *endpoints, int num_endpoints);
1395
+ int LIBUSB_CALL libusb_free_streams(libusb_device_handle *dev,
1396
+ unsigned char *endpoints, int num_endpoints);
1397
+
1390
1398
  int LIBUSB_CALL libusb_kernel_driver_active(libusb_device_handle *dev,
1391
1399
  int interface_number);
1392
1400
  int LIBUSB_CALL libusb_detach_kernel_driver(libusb_device_handle *dev,
@@ -1473,6 +1481,10 @@ struct libusb_transfer * LIBUSB_CALL libusb_alloc_transfer(int iso_packets);
1473
1481
  int LIBUSB_CALL libusb_submit_transfer(struct libusb_transfer *transfer);
1474
1482
  int LIBUSB_CALL libusb_cancel_transfer(struct libusb_transfer *transfer);
1475
1483
  void LIBUSB_CALL libusb_free_transfer(struct libusb_transfer *transfer);
1484
+ void LIBUSB_CALL libusb_transfer_set_stream_id(
1485
+ struct libusb_transfer *transfer, uint32_t stream_id);
1486
+ uint32_t LIBUSB_CALL libusb_transfer_get_stream_id(
1487
+ struct libusb_transfer *transfer);
1476
1488
 
1477
1489
  /** \ingroup asyncio
1478
1490
  * Helper function to populate the required \ref libusb_transfer fields
@@ -1548,6 +1560,34 @@ static inline void libusb_fill_bulk_transfer(struct libusb_transfer *transfer,
1548
1560
  transfer->callback = callback;
1549
1561
  }
1550
1562
 
1563
+ /** \ingroup asyncio
1564
+ * Helper function to populate the required \ref libusb_transfer fields
1565
+ * for a bulk transfer using bulk streams.
1566
+ *
1567
+ * Since version 1.0.19, \ref LIBUSB_API_VERSION >= 0x01000103
1568
+ *
1569
+ * \param transfer the transfer to populate
1570
+ * \param dev_handle handle of the device that will handle the transfer
1571
+ * \param endpoint address of the endpoint where this transfer will be sent
1572
+ * \param stream_id bulk stream id for this transfer
1573
+ * \param buffer data buffer
1574
+ * \param length length of data buffer
1575
+ * \param callback callback function to be invoked on transfer completion
1576
+ * \param user_data user data to pass to callback function
1577
+ * \param timeout timeout for the transfer in milliseconds
1578
+ */
1579
+ static inline void libusb_fill_bulk_stream_transfer(
1580
+ struct libusb_transfer *transfer, libusb_device_handle *dev_handle,
1581
+ unsigned char endpoint, uint32_t stream_id,
1582
+ unsigned char *buffer, int length, libusb_transfer_cb_fn callback,
1583
+ void *user_data, unsigned int timeout)
1584
+ {
1585
+ libusb_fill_bulk_transfer(transfer, dev_handle, endpoint, buffer,
1586
+ length, callback, user_data, timeout);
1587
+ transfer->type = LIBUSB_TRANSFER_TYPE_BULK_STREAM;
1588
+ libusb_transfer_set_stream_id(transfer, stream_id);
1589
+ }
1590
+
1551
1591
  /** \ingroup asyncio
1552
1592
  * Helper function to populate the required \ref libusb_transfer fields
1553
1593
  * for an interrupt transfer.