mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Deactivate the CameraServer by default.
Add `monitoring_feeds` property to `CameraServer`. This saves resources for games that don't use a physical camera.
This commit is contained in:
@@ -162,11 +162,25 @@ bool CameraLinux::_can_query_format(int p_file_descriptor, int p_type) {
|
||||
return ioctl(p_file_descriptor, VIDIOC_G_FMT, &format) != -1;
|
||||
}
|
||||
|
||||
CameraLinux::CameraLinux() {
|
||||
camera_thread.start(CameraLinux::camera_thread_func, this);
|
||||
inline void CameraLinux::set_monitoring_feeds(bool p_monitoring_feeds) {
|
||||
if (p_monitoring_feeds == monitoring_feeds) {
|
||||
return;
|
||||
}
|
||||
|
||||
CameraServer::set_monitoring_feeds(p_monitoring_feeds);
|
||||
if (p_monitoring_feeds) {
|
||||
camera_thread.start(CameraLinux::camera_thread_func, this);
|
||||
} else {
|
||||
exit_flag.set();
|
||||
if (camera_thread.is_started()) {
|
||||
camera_thread.wait_to_finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CameraLinux::~CameraLinux() {
|
||||
exit_flag.set();
|
||||
camera_thread.wait_to_finish();
|
||||
if (camera_thread.is_started()) {
|
||||
camera_thread.wait_to_finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ private:
|
||||
bool _can_query_format(int p_file_descriptor, int p_type);
|
||||
|
||||
public:
|
||||
CameraLinux();
|
||||
CameraLinux() = default;
|
||||
~CameraLinux();
|
||||
|
||||
void set_monitoring_feeds(bool p_monitoring_feeds) override;
|
||||
};
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
|
||||
class CameraMacOS : public CameraServer {
|
||||
public:
|
||||
CameraMacOS();
|
||||
CameraMacOS() = default;
|
||||
|
||||
void update_feeds();
|
||||
void set_monitoring_feeds(bool p_monitoring_feeds) override;
|
||||
};
|
||||
|
||||
@@ -359,10 +359,20 @@ void CameraMacOS::update_feeds() {
|
||||
};
|
||||
}
|
||||
|
||||
CameraMacOS::CameraMacOS() {
|
||||
// Find available cameras we have at this time
|
||||
update_feeds();
|
||||
void CameraMacOS::set_monitoring_feeds(bool p_monitoring_feeds) {
|
||||
if (p_monitoring_feeds == monitoring_feeds) {
|
||||
return;
|
||||
}
|
||||
|
||||
// should only have one of these....
|
||||
device_notifications = [[MyDeviceNotifications alloc] initForServer:this];
|
||||
CameraServer::set_monitoring_feeds(p_monitoring_feeds);
|
||||
if (p_monitoring_feeds) {
|
||||
// Find available cameras we have at this time.
|
||||
update_feeds();
|
||||
|
||||
// Get notified on feed changes.
|
||||
device_notifications = [[MyDeviceNotifications alloc] initForServer:this];
|
||||
} else {
|
||||
// Stop monitoring feed changes.
|
||||
device_notifications = nil;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user