diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 8954f0ed..3fafc88b 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1694,20 +1694,27 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< } else if (mPhotoInfo.mediaType == 0 && (mPhotoInfo.cameraType == CAM_TYPE_SERIAL)) { - if (photoInfo.preset != 0 && photoInfo.preset != 0xFF) + CPhoneDevice* pThis = this; + IDevice::PHOTO_INFO localPhotoInfo = mPhotoInfo; + std::thread t([localPhotoInfo, path, pThis]() mutable + { + if (localPhotoInfo.preset != 0 && localPhotoInfo.preset != 0xFF) { - CameraPhotoCmd(time(NULL), photoInfo.channel, MOVE_PRESETNO, 0, photoInfo.preset); + CameraPhotoCmd(time(NULL), localPhotoInfo.channel, MOVE_PRESETNO, 0, localPhotoInfo.preset); std::this_thread::sleep_for(std::chrono::seconds(3)); } time_t ts = time(NULL); - if(!GetPTZSensorsStatus() && !GetCameraStatus()) + if(!pThis->GetPTZSensorsStatus() && !pThis->GetCameraStatus()) { - XYLOG(XYLOG_SEVERITY_INFO, "Camera is SeltTesting, selfTestingtime = %d", photoInfo.selfTestingTime); - OpenPTZSensors(photoInfo.selfTestingTime); + XYLOG(XYLOG_SEVERITY_INFO, "Camera is SeltTesting, selfTestingtime = %d", localPhotoInfo.selfTestingTime); + pThis->OpenPTZSensors(localPhotoInfo.selfTestingTime); } - CameraPhotoCmd(ts, photoInfo.channel, 0, photoInfo.resolution, 0); + CameraPhotoCmd(ts, localPhotoInfo.channel, 0, localPhotoInfo.resolution, 0); XYLOG(XYLOG_SEVERITY_INFO, "Taking photo over"); - res = TakePTZPhotoCb(3, photoInfo); + pThis->TakePTZPhotoCb(3, localPhotoInfo); + }); + + t.detach(); } else if (mPhotoInfo.usingSysCamera == 1) {