]> git.sesse.net Git - bmusb/commitdiff
Properly initialize libusb in num_cards().
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 27 Jul 2016 19:19:53 +0000 (21:19 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 27 Jul 2016 19:19:53 +0000 (21:19 +0200)
bmusb.cpp

index 7c2108203f7904d76bdb9de9a49c8c1f3964ae3f..e9a912524b25a25e809e2f8b35c275b3f1227236 100644 (file)
--- a/bmusb.cpp
+++ b/bmusb.cpp
@@ -1013,6 +1013,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) {