Fix Gemini2L laser shutdown caused by LDP shutdown

This commit is contained in:
jj
2025-03-24 16:50:06 +08:00
parent 052846f9ef
commit 5e46ced56e
2 changed files with 44 additions and 18 deletions
+14 -1
View File
@@ -487,7 +487,20 @@ void OBCameraNode::setLdpEnableCallback(
(void)response;
bool ldp_enable = request->data;
try {
device_->setBoolProperty(OB_PROP_LDP_BOOL, ldp_enable);
if (device_->isPropertySupported(OB_PROP_LASER_CONTROL_INT, OB_PERMISSION_READ_WRITE)) {
auto laser_enable = device_->getIntProperty(OB_PROP_LASER_CONTROL_INT);
device_->setBoolProperty(OB_PROP_LDP_BOOL, ldp_enable);
device_->setIntProperty(OB_PROP_LASER_CONTROL_INT, laser_enable);
} else if (device_->isPropertySupported(OB_PROP_LASER_BOOL, OB_PERMISSION_READ_WRITE)) {
if (!ldp_enable) {
auto laser_enable = device_->getIntProperty(OB_PROP_LASER_BOOL);
device_->setBoolProperty(OB_PROP_LDP_BOOL, ldp_enable);
std::this_thread::sleep_for(std::chrono::milliseconds(3));
device_->setIntProperty(OB_PROP_LASER_BOOL, laser_enable);
} else {
device_->setBoolProperty(OB_PROP_LDP_BOOL, ldp_enable);
}
}
response->success = true;
} catch (const ob::Error& e) {
response->success = false;