MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _update_devices

Method _update_devices

modules/camera/camera_linux.cpp:56–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void CameraLinux::_update_devices() {
57 while (!exit_flag.is_set()) {
58 {
59 MutexLock lock(camera_mutex);
60
61 for (int i = feeds.size() - 1; i >= 0; i--) {
62 Ref<CameraFeedLinux> feed = (Ref<CameraFeedLinux>)feeds[i];
63 if (feed.is_null()) {
64 continue;
65 }
66 String device_name = feed->get_device_name();
67 if (!_is_active(device_name)) {
68 remove_feed(feed);
69 }
70 }
71
72 struct dirent **devices;
73 int count = scandir("/dev", &devices, nullptr, alphasort);
74
75 if (count != -1) {
76 for (int i = 0; i < count; i++) {
77 struct dirent *device = devices[i];
78 if (strncmp(device->d_name, "video", 5) == 0) {
79 String device_name = String("/dev/") + String(device->d_name);
80 if (!_has_device(device_name)) {
81 _add_device(device_name);
82 }
83 }
84 free(device);
85 }
86 }
87
88 free(devices);
89 }
90
91 call_deferred("emit_signal", SNAME(CameraServer::feeds_updated_signal_name));
92 usleep(1000000);
93 }
94}
95
96bool CameraLinux::_has_device(const String &p_device_name) {
97 for (int i = 0; i < feeds.size(); i++) {

Callers 1

camera_thread_funcMethod · 0.80

Calls 5

sizeMethod · 0.65
StringClass · 0.50
is_setMethod · 0.45
is_nullMethod · 0.45
get_device_nameMethod · 0.45

Tested by

no test coverage detected