MCPcopy Create free account
hub / github.com/OpenKinect/libfreenect2 / get_max_iso_packet_size

Function get_max_iso_packet_size

src/usb_control.cpp:133–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131 }
132
133 int get_max_iso_packet_size(libusb_device *device, int configuration, int alternate_setting, int endpoint)
134 {
135 libusb_config_descriptor *config_desc;
136 int r = LIBUSB_ERROR_NOT_FOUND;
137
138 r = libusb_get_config_descriptor_by_value(device, configuration, &config_desc);
139
140 if(r == LIBUSB_SUCCESS)
141 {
142 for(int interface_idx = 0; interface_idx < config_desc->bNumInterfaces; ++interface_idx)
143 {
144 const libusb_interface &interface = config_desc->interface[interface_idx];
145
146 if(interface.num_altsetting > alternate_setting)
147 {
148 const libusb_interface_descriptor &interface_desc = interface.altsetting[alternate_setting];
149 const libusb_endpoint_descriptor *endpoint_desc = 0;
150
151 for(int endpoint_idx = 0; endpoint_idx < interface_desc.bNumEndpoints; ++endpoint_idx)
152 {
153 if(interface_desc.endpoint[endpoint_idx].bEndpointAddress == endpoint && (interface_desc.endpoint[endpoint_idx].bmAttributes & 0x3) == LIBUSB_TRANSFER_TYPE_ISOCHRONOUS)
154 {
155 endpoint_desc = interface_desc.endpoint + endpoint_idx;
156 break;
157 }
158 }
159
160 if(endpoint_desc != 0)
161 {
162 libusb_ss_endpoint_companion_descriptor *companion_desc;
163 // ctx is only used for error reporting, libusb should better ask for a libusb_device anyway...
164 r = libusb_get_ss_endpoint_companion_descriptor(NULL /* ctx */, endpoint_desc, &companion_desc);
165
166 if(r != LIBUSB_SUCCESS) continue;
167
168 r = companion_desc->wBytesPerInterval;
169
170 libusb_free_ss_endpoint_companion_descriptor(companion_desc);
171 break;
172 }
173 }
174 }
175 }
176 libusb_free_config_descriptor(config_desc);
177
178 return r;
179 }
180}
181
182UsbControl::UsbControl(libusb_device_handle *handle) :

Callers 1

getIrMaxIsoPacketSizeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected