]> git.sesse.net Git - bmusb/blobdiff - bmusb.cpp
Support hotplugging existing devices.
[bmusb] / bmusb.cpp
index d62cef90d3db567c4af368847649762b0c34bd6c..09473fd9f6ca4f839435bedbc1e2838cd100b35e 100644 (file)
--- a/bmusb.cpp
+++ b/bmusb.cpp
@@ -1,4 +1,4 @@
-// Intensity Shuttle USB3 prototype capture driver, v0.3
+// Intensity Shuttle USB3 capture driver, v0.4
 // 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)
@@ -21,7 +21,7 @@
 #if HAS_MULTIVERSIONING
 #include <immintrin.h>
 #endif
-#include "bmusb.h"
+#include "bmusb/bmusb.h"
 
 #include <algorithm>
 #include <atomic>
@@ -48,7 +48,10 @@ using namespace std::placeholders;
 #define FRAME_SIZE (8 << 20)  // 8 MB.
 #define USB_VIDEO_TRANSFER_SIZE (128 << 10)  // 128 kB.
 
+namespace bmusb {
+
 card_connected_callback_t BMUSBCapture::card_connected_callback = nullptr;
+bool BMUSBCapture::hotplug_existing_devices = false;
 
 namespace {
 
@@ -1344,7 +1347,7 @@ void BMUSBCapture::start_bm_thread()
        // coming back with errors, so only care about devices joining.
        if (card_connected_callback != nullptr) {
                if (libusb_hotplug_register_callback(
-                       nullptr, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, LIBUSB_HOTPLUG_NO_FLAGS,
+                       nullptr, LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, hotplug_existing_devices ? LIBUSB_HOTPLUG_ENUMERATE : LIBUSB_HOTPLUG_NO_FLAGS,
                        USB_VENDOR_BLACKMAGIC, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY,
                        &BMUSBCapture::cb_hotplug, nullptr, nullptr) < 0) {
                        fprintf(stderr, "libusb_hotplug_register_callback() failed\n");
@@ -1426,3 +1429,5 @@ void BMUSBCapture::update_capture_mode()
                exit(1);
        }
 }
+
+}  // namespace bmusb