diff options
author | Tormod Volden <debian.tormod@gmail.com> | 2022-04-03 15:35:00 +0200 |
---|---|---|
committer | Tormod Volden <debian.tormod@gmail.com> | 2022-04-04 13:38:45 +0200 |
commit | bfbef179b12110d8d8fc6ff9e4af5f96a37a78ab (patch) | |
tree | b81e28bdbc8f28c46553dcbdf40e4205785e5abb | |
parent | bfa8b8535a929e939d549d9c3778592abfafe870 (diff) | |
download | libusb-bfbef179b12110d8d8fc6ff9e4af5f96a37a78ab.tar.gz |
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>
-rw-r--r-- | libusb/os/windows_winusb.c | 11 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 11 insertions, 2 deletions
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 @@ static enum libusb_transfer_status winusbx_copy_transfer_data(int sub_api, struc // 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 @@ static enum libusb_transfer_status winusbx_copy_transfer_data(int sub_api, struc } 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 |