| 136 | } |
| 137 | |
| 138 | static std::vector<USBDeviceInfo> getHotplugBasedDeviceList() |
| 139 | { |
| 140 | static std::vector<USBDeviceInfo> devices; |
| 141 | static bool hotplugSetupDone = false; |
| 142 | |
| 143 | if (!hotplugSetupDone) { |
| 144 | hotplugSetupDone = true; |
| 145 | devices = pollUSBDevices(); |
| 146 | |
| 147 | int ret = libusb_hotplug_register_callback( |
| 148 | nullptr, |
| 149 | LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | |
| 150 | LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT, |
| 151 | 0, LIBUSB_HOTPLUG_MATCH_ANY, LIBUSB_HOTPLUG_MATCH_ANY, |
| 152 | LIBUSB_HOTPLUG_MATCH_ANY, hotplugCallback, &devices, |
| 153 | nullptr); |
| 154 | if (ret != LIBUSB_SUCCESS) { |
| 155 | hotplugsAreSupported = false; |
| 156 | } else { |
| 157 | blog(LOG_WARNING, LOG_PREFIX "hotplug supported!"); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | std::lock_guard<std::mutex> lock(mutex); |
| 162 | return devices; |
| 163 | } |
| 164 | |
| 165 | static std::vector<USBDeviceInfo> getPollingBasedDeviceList() |
| 166 | { |
nothing calls this directly
no test coverage detected