@@ -50,6 +50,10 @@ static bool isMtpDevice(uint16_t vendor, uint16_t product) {
50
50
}
51
51
#endif
52
52
53
+ #ifdef HAS_USBHOST_TIMEOUT
54
+ static const int USB_CONTROL_TRANSFER_TIMEOUT_MS = 200 ;
55
+ #endif
56
+
53
57
MtpDevice* MtpDevice::open (const char * deviceName, int fd) {
54
58
struct usb_device *device = usb_device_new (deviceName, fd);
55
59
if (!device) {
@@ -70,15 +74,24 @@ MtpDevice* MtpDevice::open(const char* deviceName, int fd) {
70
74
interface->bInterfaceSubClass == 1 && // Still Image Capture
71
75
interface->bInterfaceProtocol == 1 ) // Picture Transfer Protocol (PIMA 15470)
72
76
{
77
+ #ifdef HAS_USBHOST_TIMEOUT
78
+ char * manufacturerName = usb_device_get_manufacturer_name (device, USB_CONTROL_TRANSFER_TIMEOUT_MS);
79
+ char * productName = usb_device_get_product_name (device, USB_CONTROL_TRANSFER_TIMEOUT_MS);
80
+ #else
73
81
char * manufacturerName = usb_device_get_manufacturer_name (device);
74
82
char * productName = usb_device_get_product_name (device);
83
+ #endif
75
84
MTPD (" Found camera: \" %s\" \" %s\"\n " , manufacturerName, productName);
76
85
free (manufacturerName);
77
86
free (productName);
78
87
} else if (interface->bInterfaceClass == 0xFF &&
79
88
interface->bInterfaceSubClass == 0xFF &&
80
89
interface->bInterfaceProtocol == 0 ) {
90
+ #ifdef HAS_USBHOST_TIMEOUT
91
+ char * interfaceName = usb_device_get_string (device, interface->iInterface , USB_CONTROL_TRANSFER_TIMEOUT_MS);
92
+ #else
81
93
char * interfaceName = usb_device_get_string (device, interface->iInterface );
94
+ #endif
82
95
if (!interfaceName) {
83
96
continue ;
84
97
} else if (strcmp (interfaceName, " MTP" )) {
@@ -88,8 +101,13 @@ MtpDevice* MtpDevice::open(const char* deviceName, int fd) {
88
101
free (interfaceName);
89
102
90
103
// Looks like an android style MTP device
104
+ #ifdef HAS_USBHOST_TIMEOUT
105
+ char * manufacturerName = usb_device_get_manufacturer_name (device, USB_CONTROL_TRANSFER_TIMEOUT_MS);
106
+ char * productName = usb_device_get_product_name (device, USB_CONTROL_TRANSFER_TIMEOUT_MS);
107
+ #else
91
108
char * manufacturerName = usb_device_get_manufacturer_name (device);
92
109
char * productName = usb_device_get_product_name (device);
110
+ #endif
93
111
MTPI (" Found MTP device: \" %s\" \" %s\"\n " , manufacturerName, productName);
94
112
free (manufacturerName);
95
113
free (productName);
0 commit comments