From a4905d0e32d65bee0adb455b32ecbb49b5491257 Mon Sep 17 00:00:00 2001 From: Sunid Wilson Date: Mon, 19 Mar 2012 11:46:47 -0700 Subject: camera: Send proper preview window updates to HAL During setPreviewWindow call camera_preview_window instance will be passed to the HAL. camera_preview_window instance will never change when ANativeWindow is updated. Hence HAL tries to use old preview window handle not knowing that the preview window is updated. Added the check in camera interface to reset the preview handle based on whether ANativeWindow instance is changed or not. CRs-Fixed: 341892 Change-Id: I6743f24cbd4467025d6fe21098c7ce6813017d5e Frameworks: Allow CameraService to set window when preview is not running Change-Id: Iab3f652ed3a7639c660e85c98a837215985a3296 Camera: Enable metadata callback after snapshot Change-Id: I734fc596b7549d4dcc00aee466e1c4be02e38c8d CRs-fixed: 346728 --- .../libcameraservice/CameraHardwareInterface.h | 5 ++++ services/camera/libcameraservice/CameraService.cpp | 32 +++++++++++++++++++--- services/camera/libcameraservice/CameraService.h | 4 ++- 3 files changed, 36 insertions(+), 5 deletions(-) mode change 100644 => 100755 services/camera/libcameraservice/CameraHardwareInterface.h diff --git a/services/camera/libcameraservice/CameraHardwareInterface.h b/services/camera/libcameraservice/CameraHardwareInterface.h old mode 100644 new mode 100755 index 57f923f..9a29e8f --- 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, (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, 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& 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& mem) { if (!mburstCnt) { LOG1("mburstCnt = %d", mburstCnt); disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE); +#ifdef QCOM_HARDWARE + if (mFaceDetection) { + enableMsgType(CAMERA_MSG_PREVIEW_METADATA); + } +#endif } sp 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. -- cgit v1.1