]> git.sesse.net Git - bmusb/blobdiff - bmusb.cpp
Make FakeCapture output 8-channel sound, to match the real cards.
[bmusb] / bmusb.cpp
index 7c2108203f7904d76bdb9de9a49c8c1f3964ae3f..080c0bb0dae65f649ee34e5ba26ab023092a5fbf 100644 (file)
--- a/bmusb.cpp
+++ b/bmusb.cpp
@@ -1,4 +1,4 @@
-// Intensity Shuttle USB3 capture driver, v0.4
+// Intensity Shuttle USB3 capture driver, v0.5.1
 // Can download 8-bit and 10-bit UYVY/v210 frames from HDMI, quite stable
 // (can do captures for hours at a time with no drops), except during startup
 // 576p60/720p60/1080i60 works, 1080p60 does not work (firmware limitation)
@@ -878,7 +878,8 @@ void BMUSBCapture::usb_thread_func()
                printf("couldn't set realtime priority for USB thread: %s\n", strerror(errno));
        }
        while (!should_quit) {
-               int rc = libusb_handle_events(nullptr);
+               timeval sec { 1, 0 };
+               int rc = libusb_handle_events_timeout(nullptr, &sec);
                if (rc != LIBUSB_SUCCESS)
                        break;
        }
@@ -1013,6 +1014,12 @@ libusb_device_handle *open_card(unsigned card_index, libusb_device *dev, string
 
 unsigned BMUSBCapture::num_cards()
 {
+       int rc = libusb_init(nullptr);
+       if (rc < 0) {
+               fprintf(stderr, "Error initializing libusb: %s\n", libusb_error_name(rc));
+               exit(1);
+       }
+
        vector<USBCardDevice> found_cards = find_all_cards();
        unsigned ret = found_cards.size();
        for (size_t i = 0; i < found_cards.size(); ++i) {
@@ -1098,6 +1105,11 @@ void BMUSBCapture::configure_card()
        rc = libusb_set_interface_alt_setting(devh, /*interface=*/0, /*alternate_setting=*/1);
        if (rc < 0) {
                fprintf(stderr, "Error setting alternate 1: %s\n", libusb_error_name(rc));
+               if (rc == LIBUSB_ERROR_NOT_FOUND) {
+                       fprintf(stderr, "This is usually because the card came up in USB2 mode.\n");
+                       fprintf(stderr, "In particular, this tends to happen if you boot up with the\n");
+                       fprintf(stderr, "card plugged in; just unplug and replug it, and it usually works.\n");
+               }
                exit(1);
        }
        rc = libusb_set_interface_alt_setting(devh, /*interface=*/0, /*alternate_setting=*/2);