summaryrefslogtreecommitdiffhomepage
path: root/video-ps3eye/PS3EYEDriver/singleton.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-05-05 12:34:01 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-05-06 03:42:13 +0200
commit6eda8a85b84c4e661a8763429ae1978f8da7f9dd (patch)
tree5169e1bf6779f7442235f36a206a91e224cda05d /video-ps3eye/PS3EYEDriver/singleton.hpp
parent12dfd6dcf60d9fefef7f8723fb9bc5a21fdb5b61 (diff)
video/ps3eye: WIP
Diffstat (limited to 'video-ps3eye/PS3EYEDriver/singleton.hpp')
-rw-r--r--video-ps3eye/PS3EYEDriver/singleton.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/video-ps3eye/PS3EYEDriver/singleton.hpp b/video-ps3eye/PS3EYEDriver/singleton.hpp
new file mode 100644
index 00000000..7e8dc23c
--- /dev/null
+++ b/video-ps3eye/PS3EYEDriver/singleton.hpp
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <vector>
+#include <memory>
+#include <thread>
+#include <atomic>
+
+struct libusb_context;
+struct ps3eye_camera;
+
+struct USBMgr
+{
+ USBMgr();
+ ~USBMgr();
+ USBMgr(const USBMgr&) = delete;
+ void operator=(const USBMgr&) = delete;
+
+ static USBMgr& instance();
+ int list_devices(std::vector<std::shared_ptr<ps3eye_camera>>& list);
+ void camera_started();
+ void camera_stopped();
+
+private:
+ libusb_context* usb_context = nullptr;
+ std::thread update_thread;
+ std::atomic_int active_camera_count = 0;
+ std::atomic_bool exit_signaled = false;
+
+ void start_xfer_thread();
+ void stop_xfer_thread();
+ void transfer_loop();
+};