release-request-fad05353-cc19-4c26-af2f-d5c8a574970e-for-git_oc-mr1-release-4057695 snap-temp-L92600000069427650
Change-Id: I766f473528d77cd273cd0cd4d16c3041793b1df7
diff --git a/examples/detect.c b/examples/detect.c
index 393fd2c..3bc21e7 100644
--- a/examples/detect.c
+++ b/examples/detect.c
@@ -218,7 +218,8 @@
file->item_id,
tmpfiledescriptor,
NULL,
- NULL);
+ NULL,
+ NULL);
if (ret == 0) {
uint8_t *buf = NULL;
uint32_t readbytes;
diff --git a/src/libmtp.c b/src/libmtp.c
index b8dc50e..8c86cde 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -5787,8 +5787,12 @@
if (FLAG_ONLY_7BIT_FILENAMES(ptp_usb)) {
strip_7bit_from_utf8(new_file.Filename);
}
- // We lose precision here.
- new_file.ObjectCompressedSize = (uint32_t) filedata->filesize;
+ if (filedata->filesize > 0xFFFFFFFFL) {
+ // This is a kludge in the MTP standard for large files.
+ new_file.ObjectCompressedSize = (uint32_t) 0xFFFFFFFF;
+ } else {
+ new_file.ObjectCompressedSize = (uint32_t) filedata->filesize;
+ }
new_file.ObjectFormat = of;
new_file.StorageID = store;
new_file.ParentObject = localph;
diff --git a/src/libusb-glue.c b/src/libusb-glue.c
index cdddfca..e46cfc5 100644
--- a/src/libusb-glue.c
+++ b/src/libusb-glue.c
@@ -805,6 +805,7 @@
#define CONTEXT_BLOCK_SIZE_1 0x3e00
#define CONTEXT_BLOCK_SIZE_2 0x200
#define CONTEXT_BLOCK_SIZE CONTEXT_BLOCK_SIZE_1+CONTEXT_BLOCK_SIZE_2
+
static short
ptp_read_func (
unsigned long size, PTPDataHandler *handler,void *data,
@@ -818,6 +819,23 @@
unsigned long written;
unsigned char *bytes;
int expect_terminator_byte = 0;
+ unsigned long usb_inep_maxpacket_size;
+ unsigned long context_block_size_1;
+ unsigned long context_block_size_2;
+ uint16_t ptp_dev_vendor_id = ptp_usb->rawdevice.device_entry.vendor_id;
+
+ //"iRiver" device special handling
+ if (ptp_dev_vendor_id == 0x4102 || ptp_dev_vendor_id == 0x1006) {
+ usb_inep_maxpacket_size = ptp_usb->inep_maxpacket;
+ if (usb_inep_maxpacket_size == 0x400) {
+ context_block_size_1 = CONTEXT_BLOCK_SIZE_1 - 0x200;
+ context_block_size_2 = CONTEXT_BLOCK_SIZE_2 + 0x200;
+ }
+ else {
+ context_block_size_1 = CONTEXT_BLOCK_SIZE_1;
+ context_block_size_2 = CONTEXT_BLOCK_SIZE_2;
+ }
+ }
// This is the largest block we'll need to read in.
bytes = malloc(CONTEXT_BLOCK_SIZE);
@@ -1235,6 +1253,10 @@
PTPDataHandler memhandler;
uint16_t ret;
unsigned char *x = NULL;
+ unsigned long packet_size;
+ PTP_USB *ptp_usb = (PTP_USB *) params->data;
+
+ packet_size = ptp_usb->inep_maxpacket;
/* read the header and potentially the first data */
if (params->response_packet_size > 0) {
@@ -1248,7 +1270,7 @@
return PTP_RC_OK;
}
ptp_init_recv_memory_handler (&memhandler);
- ret = ptp_read_func(PTP_USB_BULK_HS_MAX_PACKET_LEN_READ, &memhandler, params->data, rlen, 0);
+ ret = ptp_read_func(packet_size, &memhandler, params->data, rlen, 0);
ptp_exit_recv_memory_handler (&memhandler, &x, rlen);
if (x) {
memcpy (packet, x, *rlen);