summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTormod Volden <debian.tormod@gmail.com>2022-02-02 16:12:25 +0100
committerTormod Volden <debian.tormod@gmail.com>2022-03-20 09:49:41 +0100
commitf939c8aabaaa42739e294df12cbac9e6a87a708a (patch)
tree4e65a330a9399ceb4fb18fc7b6fcbbbec6065380
parentf5275f9a87db898af56060958df182ef7e5c1240 (diff)
downloadlibusb-f939c8aabaaa42739e294df12cbac9e6a87a708a.tar.gz
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>
-rw-r--r--libusb/os/darwin_usb.c42
-rw-r--r--libusb/version_nano.h2
2 files changed, 34 insertions, 10 deletions
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 @@ static enum libusb_error get_endpoints (struct libusb_device_handle *dev_handle,
/* 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 @@ static enum libusb_error get_endpoints (struct libusb_device_handle *dev_handle,
/* 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 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
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 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
}
/* 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 @@ static int submit_iso_transfer(struct usbi_transfer *itransfer) {
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