darwin: update the list of endpoints after successfull SetAlternateInterface()
authorDmitry Zakablukov <dimaz@passware.com>
Tue, 13 Jul 2021 14:50:28 +0000 (17:50 +0300)
committerNathan Hjelm <hjelmn@google.com>
Tue, 20 Jul 2021 13:56:30 +0000 (07:56 -0600)
Closes #950

Signed-off-by: Nathan Hjelm <hjelmn@google.com>
libusb/os/darwin_usb.c
libusb/version_nano.h

index d763c9db845b13335941999eca206b7cf535b105..ff268002cd8d6d20d9ad25edd28fa6456f1dd016 100644 (file)
@@ -1582,7 +1582,17 @@ static int darwin_set_interface_altsetting(struct libusb_device_handle *dev_hand
     return LIBUSB_ERROR_NO_DEVICE;
 
   kresult = (*(cInterface->interface))->SetAlternateInterface (cInterface->interface, altsetting);
-  if (kresult != kIOReturnSuccess)
+  if (kresult == kIOReturnSuccess) {
+    /* update the list of endpoints */
+    ret = get_endpoints (dev_handle, iface);
+    if (ret) {
+      /* this should not happen */
+      darwin_release_interface (dev_handle, iface);
+      usbi_err (HANDLE_CTX (dev_handle), "could not build endpoint table");
+    }
+    return ret;
+  }
+  else
     usbi_warn (HANDLE_CTX (dev_handle), "SetAlternateInterface: %s", darwin_error_str(kresult));
 
   if (kresult != kIOUSBPipeStalled)
index ca4698121cc1c85a671cbb4eca3fd8ca0eda1de8..9582feef57def9e15416e226387b3af3db455786 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11637
+#define LIBUSB_NANO 11638