darwin: Always use GetPipePropertiesV3 when available
The V3 API goes back to macOS 10.8.2 (2012), and we have already been
using it when targeting 10.9 or higher for a while. However in a few
places we were still using the older API.
Affects get_endpoints() and submit_iso_transfer().
In the latter also:
- Check success of pipe properties retrieval.
- Remove a duplicate call to GetPipeProperties().
References #919
Closes #1056
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c
index a22ab30..3b9fd84 100644
--- a/libusb/os/darwin_usb.c
+++ b/libusb/os/darwin_usb.c
@@ -1389,12 +1389,16 @@
/* current interface */
struct darwin_interface *cInterface = &priv->interfaces[iface];
+#if InterfaceVersion >= 550
+ IOUSBEndpointProperties pipeProperties = {.bVersion = kUSBEndpointPropertiesVersion3};
+#else
+ UInt8 dont_care1, dont_care3;
+ UInt16 dont_care2;
+#endif
IOReturn kresult;
UInt8 numep, direction, number;
- UInt8 dont_care1, dont_care3;
- UInt16 dont_care2;
int rc;
struct libusb_context *ctx = HANDLE_CTX (dev_handle);
@@ -1410,9 +1414,14 @@
/* iterate through pipe references */
for (UInt8 i = 1 ; i <= numep ; i++) {
+#if InterfaceVersion >= 550
+ kresult = (*(cInterface->interface))->GetPipePropertiesV3 (cInterface->interface, i, &pipeProperties);
+ number = pipeProperties.bEndpointNumber;
+ direction = pipeProperties.bDirection;
+#else
kresult = (*(cInterface->interface))->GetPipeProperties(cInterface->interface, i, &direction, &number, &dont_care1,
&dont_care2, &dont_care3);
-
+#endif
if (kresult != kIOReturnSuccess) {
/* probably a buggy device. try to get the endpoint address from the descriptors */
struct libusb_config_descriptor *config;
@@ -2024,11 +2033,17 @@
struct darwin_transfer_priv *tpriv = usbi_get_transfer_priv(itransfer);
IOReturn kresult;
- uint8_t direction, number, interval, pipeRef, transferType;
- uint16_t maxPacketSize;
+ uint8_t pipeRef, interval;
UInt64 frame;
AbsoluteTime atTime;
int i;
+#if InterfaceVersion >= 550
+ IOUSBEndpointProperties pipeProperties = {.bVersion = kUSBEndpointPropertiesVersion3};
+#else
+ /* None of the values below are used in libusb for iso transfers */
+ uint8_t direction, number, transferType;
+ uint16_t maxPacketSize;
+#endif
struct darwin_interface *cInterface;
@@ -2060,8 +2075,20 @@
}
/* determine the properties of this endpoint and the speed of the device */
- (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
+#if InterfaceVersion >= 550
+ kresult = (*(cInterface->interface))->GetPipePropertiesV3 (cInterface->interface, pipeRef, &pipeProperties);
+ interval = pipeProperties.bInterval;
+#else
+ kresult = (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
&transferType, &maxPacketSize, &interval);
+#endif
+ if (kresult != kIOReturnSuccess) {
+ usbi_err (TRANSFER_CTX (transfer), "failed to get pipe properties: %d", kresult);
+ free(tpriv->isoc_framelist);
+ tpriv->isoc_framelist = NULL;
+
+ return darwin_to_libusb (kresult);
+ }
/* Last but not least we need the bus frame number */
kresult = (*(cInterface->interface))->GetBusFrameNumber(cInterface->interface, &frame, &atTime);
@@ -2073,9 +2100,6 @@
return darwin_to_libusb (kresult);
}
- (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number,
- &transferType, &maxPacketSize, &interval);
-
/* schedule for a frame a little in the future */
frame += 4;
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 6d64606..346fcb8 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11709
+#define LIBUSB_NANO 11710