windows: Update isochronous OUT packet actual length
On Windows, unlike other platforms, the isochronous packet actual_length
value is not set on completion of OUT transfers. However, our API
requires the user to check this value for isochronous transfers instead
of the transfer actual_length, if the transferred length is of interest.
The usbd Length field is not used for isochronous OUT transfers:
https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/usb/ns-usb-_usbd_iso_packet_descriptor
To make it consistent with other platforms, just return the requested
length.
Fixes #1105
Closes #1107
Tested-by: Xiaofan Chen <xiaofanc@gmail.com>
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
index ab49975..ffc1612 100644
--- a/libusb/os/windows_winusb.c
+++ b/libusb/os/windows_winusb.c
@@ -3245,7 +3245,13 @@
// iso only supported on libusbk-based backends for now
PKISO_CONTEXT iso_context = transfer_priv->iso_context;
for (i = 0; i < transfer->num_iso_packets; i++) {
- transfer->iso_packet_desc[i].actual_length = iso_context->IsoPackets[i].actual_length;
+ if (IS_XFERIN(transfer)) {
+ transfer->iso_packet_desc[i].actual_length = iso_context->IsoPackets[i].actual_length;
+ } else {
+ // On Windows the usbd Length field is not used for OUT transfers.
+ // Copy the requested value back for consistency with other platforms.
+ transfer->iso_packet_desc[i].actual_length = transfer->iso_packet_desc[i].length;
+ }
// TODO translate USDB_STATUS codes http://msdn.microsoft.com/en-us/library/ff539136(VS.85).aspx to libusb_transfer_status
//transfer->iso_packet_desc[i].status = transfer_priv->iso_context->IsoPackets[i].status;
}
@@ -3266,6 +3272,9 @@
} else {
for (i = 0; i < transfer->num_iso_packets; i++) {
transfer->iso_packet_desc[i].status = LIBUSB_TRANSFER_COMPLETED;
+ // On Windows the usbd Length field is not used for OUT transfers.
+ // Copy the requested value back for consistency with other platforms.
+ transfer->iso_packet_desc[i].actual_length = transfer->iso_packet_desc[i].length;
}
}
} else {
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index ae65857..a04468b 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11719
+#define LIBUSB_NANO 11720