- libusb_get_configuration(dev, ¤t_configuration);
- if (current_configuration != KINECT_AUDIO_CONFIGURATION)
- libusb_set_configuration(dev, KINECT_AUDIO_CONFIGURATION);
+ ret = libusb_get_configuration(dev, ¤t_configuration);
+ if (ret < 0) {
+ fprintf(stderr, "libusb_get_configuration failed: %s\n",
+ libusb_error_name(ret));
+ goto out_libusb_close;
+ }
+
+ if (current_configuration != KINECT_AUDIO_CONFIGURATION) {
+ ret = libusb_set_configuration(dev, KINECT_AUDIO_CONFIGURATION);
+ if (ret < 0) {
+ fprintf(stderr, "libusb_set_configuration failed: %s\n",
+ libusb_error_name(ret));
+ fprintf(stderr, "Cannot set configuration %d\n",
+ KINECT_AUDIO_CONFIGURATION);
+ goto out_libusb_close;
+ }
+ }
+
+ libusb_set_auto_detach_kernel_driver(dev, 1);