diff options
-rwxr-xr-x[-rw-r--r--] | services/camera/libcameraservice/CameraHardwareInterface.h | 5 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraService.cpp | 32 | ||||
-rw-r--r-- | services/camera/libcameraservice/CameraService.h | 4 |
3 files changed, 36 insertions, 5 deletions
diff --git a/services/camera/libcameraservice/CameraHardwareInterface.h b/services/camera/libcameraservice/CameraHardwareInterface.h index 57f923f..9a29e8f 100644..100755 --- a/services/camera/libcameraservice/CameraHardwareInterface.h +++ b/services/camera/libcameraservice/CameraHardwareInterface.h @@ -115,6 +115,11 @@ public: LOGV("%s(%s) buf %p", __FUNCTION__, mName.string(), buf.get()); if (mDevice->ops->set_preview_window) { + LOGV("%s buf %p mPreviewWindow %p", __FUNCTION__, buf.get(), mPreviewWindow.get()); + if (mPreviewWindow.get() && (buf.get() != mPreviewWindow.get())) { + mDevice->ops->set_preview_window(mDevice, 0); + } + mPreviewWindow = buf; mHalPreviewWindow.user = this; LOGV("%s &mHalPreviewWindow %p mHalPreviewWindow.user %p", __FUNCTION__, diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index f6825d7..8d95d65 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -374,8 +374,11 @@ CameraService::Client::Client(const sp<CameraService>& cameraService, (void *)cameraId); // Enable zoom, error, focus, and metadata messages by default - enableMsgType(CAMERA_MSG_ERROR | CAMERA_MSG_ZOOM | CAMERA_MSG_FOCUS | - CAMERA_MSG_PREVIEW_METADATA); + enableMsgType(CAMERA_MSG_ERROR | CAMERA_MSG_ZOOM | CAMERA_MSG_FOCUS +#ifndef QCOM_HARDWARE + | CAMERA_MSG_PREVIEW_METADATA +#endif + ); // Callback is disabled by default mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP; @@ -383,6 +386,9 @@ CameraService::Client::Client(const sp<CameraService>& cameraService, mPlayShutterSound = true; cameraService->setCameraBusy(cameraId); cameraService->loadSound(); +#ifdef QCOM_HARDWARE + mFaceDetection = false; +#endif LOG1("Client::Client X (pid %d)", callingPid); } @@ -522,9 +528,9 @@ void CameraService::Client::disconnect() { // Release the held ANativeWindow resources. if (mPreviewWindow != 0) { + mHardware->setPreviewWindow(0); disconnectWindow(mPreviewWindow); mPreviewWindow = 0; - mHardware->setPreviewWindow(mPreviewWindow); } mHardware.clear(); @@ -564,6 +570,8 @@ status_t CameraService::Client::setPreviewWindow(const sp<IBinder>& binder, native_window_set_buffers_transform(window.get(), mOrientation); result = mHardware->setPreviewWindow(window); } + } else { + result = mHardware->setPreviewWindow(window); } if (result == NO_ERROR) { @@ -623,7 +631,10 @@ void CameraService::Client::setPreviewCallbackFlag(int callback_flag) { // start preview mode status_t CameraService::Client::startPreview() { LOG1("startPreview (pid %d)", getCallingPid()); - enableMsgType(CAMERA_MSG_PREVIEW_METADATA); +#ifdef QCOM_HARDWARE + if (mFaceDetection) + enableMsgType(CAMERA_MSG_PREVIEW_METADATA); +#endif return startCameraMode(CAMERA_PREVIEW_MODE); } @@ -908,6 +919,14 @@ status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t a } else if (cmd == CAMERA_CMD_HISTOGRAM_OFF) { disableMsgType(CAMERA_MSG_STATS_DATA); +#ifdef QCOM_HARDWARE + } else if (cmd == CAMERA_CMD_START_FACE_DETECTION) { + mFaceDetection = true; + enableMsgType(CAMERA_MSG_PREVIEW_METADATA); + } else if (cmd == CAMERA_CMD_STOP_FACE_DETECTION) { + mFaceDetection = false; + disableMsgType(CAMERA_MSG_PREVIEW_METADATA); +#endif } @@ -1161,6 +1180,11 @@ void CameraService::Client::handleCompressedPicture(const sp<IMemory>& mem) { if (!mburstCnt) { LOG1("mburstCnt = %d", mburstCnt); disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); +#ifdef QCOM_HARDWARE + if (mFaceDetection) { + enableMsgType(CAMERA_MSG_PREVIEW_METADATA); + } +#endif } sp<ICameraClient> c = mCameraClient; mLock.unlock(); diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h index 0d29105..33f7226 100644 --- a/services/camera/libcameraservice/CameraService.h +++ b/services/camera/libcameraservice/CameraService.h @@ -182,7 +182,9 @@ private: int mPreviewCallbackFlag; int mOrientation; // Current display orientation bool mPlayShutterSound; - +#ifdef QCOM_HARDWARE + bool mFaceDetection; +#endif // Ensures atomicity among the public methods mutable Mutex mLock; // This is a binder of Surface or SurfaceTexture. |