X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bmusb.cpp;h=5fda2177cd33ee19e0630bdff3a049ab42f8c43e;hb=e0837a17b5a497476d67237c768836e51f8a4ce7;hp=fd323a66ffc42bc8a025ba4e6353f7e7a6c37acd;hpb=28c6df233b806a580281eb1ae242fa108af3eb09;p=bmusb diff --git a/bmusb.cpp b/bmusb.cpp index fd323a6..5fda217 100644 --- a/bmusb.cpp +++ b/bmusb.cpp @@ -1,4 +1,4 @@ -// Intensity Shuttle USB3 capture driver, v0.4 +// Intensity Shuttle USB3 capture driver, v0.5 // 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; } @@ -1011,10 +1012,16 @@ libusb_device_handle *open_card(unsigned card_index, libusb_device *dev, string } // namespace -int BMUSBCapture::num_cards() +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 found_cards = find_all_cards(); - int ret = found_cards.size(); + unsigned ret = found_cards.size(); for (size_t i = 0; i < found_cards.size(); ++i) { libusb_unref_device(found_cards[i].device); }