From d55b2fdafb31f1c85a611f9c5438d47a54535a59 Mon Sep 17 00:00:00 2001 From: Nathan Hjelm Date: Thu, 11 Jun 2020 23:31:36 -0600 Subject: [PATCH] darwin: use GetPipePropertiesV3 on 10.9 and later Apple added the GetPipePropertiesV3 in IOUSBFamily version 550. The old function appears to be deprecated. When 10.8.x and older are no longer supported the GetPipeProperties call should be removed. Signed-off-by: Nathan Hjelm --- libusb/os/darwin_usb.c | 16 ++++++++++++++-- libusb/version_nano.h | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index e6e4943..a1474ba 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -1770,11 +1770,16 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) { IOReturn ret; uint8_t transferType; - /* None of the values below are used in libusbx for bulk transfers */ - uint8_t direction, number, interval, pipeRef; + uint8_t pipeRef; uint16_t maxPacketSize; struct darwin_interface *cInterface; +#if InterfaceVersion >= 550 + IOUSBEndpointProperties pipeProperties; +#else + /* None of the values below are used in libusb for bulk transfers */ + uint8_t direction, number, interval; +#endif if (ep_to_pipeRef (transfer->dev_handle, transfer->endpoint, &pipeRef, NULL, &cInterface) != 0) { usbi_err (TRANSFER_CTX (transfer), "endpoint not found on any open interface"); @@ -1782,8 +1787,15 @@ static int submit_bulk_transfer(struct usbi_transfer *itransfer) { return LIBUSB_ERROR_NOT_FOUND; } +#if InterfaceVersion >= 550 + ret = (*(cInterface->interface))->GetPipePropertiesV3 (cInterface->interface, pipeRef, &pipeProperties); + + transferType = pipeProperties.bTransferType; + maxPacketSize = pipeProperties.wMaxPacketSize; +#else ret = (*(cInterface->interface))->GetPipeProperties (cInterface->interface, pipeRef, &direction, &number, &transferType, &maxPacketSize, &interval); +#endif if (ret) { usbi_err (TRANSFER_CTX (transfer), "bulk transfer failed (dir = %s): %s (code = 0x%08x)", IS_XFERIN(transfer) ? "In" : "Out", diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 2b653c5..2b710bd 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11519 +#define LIBUSB_NANO 11520 -- 2.7.4