From 0f658a0e1b4d78723d581f4893f013154ee3e174 Mon Sep 17 00:00:00 2001 From: KyungYoun Date: Thu, 2 May 2013 14:02:53 +0900 Subject: [PATCH] CAF state bug fix Change-Id: I1e90517bd155a60e33e82c1aa9215311c7b5c886 Signed-off-by: KyungYoun --- src/FMedia_CameraImpl.cpp | 75 +++++++++++++++++++++++++++++------------------ src/FMedia_CameraImpl.h | 8 ++--- 2 files changed, 51 insertions(+), 32 deletions(-) diff --git a/src/FMedia_CameraImpl.cpp b/src/FMedia_CameraImpl.cpp index e50307e..9a01324 100755 --- a/src/FMedia_CameraImpl.cpp +++ b/src/FMedia_CameraImpl.cpp @@ -75,10 +75,11 @@ static const int _RELOAD_INTERNAL_PREVIEW_FORMAT = 0x1 << 20; static const int _RELOAD_FOCUS_MODE = 0x1 << 21; static const int _RELOAD_ZERO_SHUTTER_LAG = 0x1 << 22; static const int _RELOAD_METERING_MODE = 0x1 << 23; -static const int _RELOAD_SCENE_MODE_SET = 0x1 << 24; +static const int _RELOAD_SCENE_MODE = 0x1 << 24; static const int _RELOAD_EXTRA = 0x1 << 25; -static const int _RELOAD_SCEN_MODE_OFF = _RELOAD_BRIGHTNESS | _RELOAD_WB |_RELOAD_ISO | _RELOAD_METERING_MODE | _RELOAD_FOCUS_MODE | _RELOAD_FLASH; +static const int _RELOAD_NO_SCEN_MODE = _RELOAD_BRIGHTNESS | _RELOAD_WB |_RELOAD_ISO | _RELOAD_METERING_MODE | _RELOAD_FLASH; +static const int _RELOAD_NO_SCEN_MODE_AFTER_PREVIEW = _RELOAD_FOCUS_MODE; static const int _PREVIEW_PRE_PROCESSING = 0x01; static const int _PREVIEW_POST_PROCESSING = 0x01 << 1; @@ -206,6 +207,7 @@ _CameraImpl::_CameraImpl(void) , __fps(DEFAULT_CAMERA_PREVIEW_FPS) #endif , __focusMode(CAMERA_FOCUS_MODE_NONE) + , __currentFocusMode(CAMERA_FOCUS_MODE_NONE) , __previewProcessing(0) , __previewRegionHandle(_BufferInfoImpl::INVALID_BUFFER_HANDLE) , __previewDisplayType(::CAMERA_DISPLAY_TYPE_NONE) @@ -438,12 +440,12 @@ _CameraImpl::PowerOn(void) // re-configuration for new camera handle. active conf. if (__sceneMode == CAMERA_SCENE_OFF) { - r = ReloadConfiguration(_RELOAD_SCEN_MODE_OFF); + r = ReloadConfiguration(_RELOAD_NO_SCEN_MODE); SysTryCatch(NID_MEDIA, r == E_SUCCESS, r=E_DEVICE_FAILED, E_DEVICE_FAILED, "[E_DEVICE_FAILED] Scen off mode configuration failed. Converted from [%s]", GetErrorMessage(r)); } else { - r = ReloadConfiguration(_RELOAD_SCENE_MODE_SET); + r = ReloadConfiguration(_RELOAD_SCENE_MODE); SysTryCatch(NID_MEDIA, r == E_SUCCESS, r=E_DEVICE_FAILED, E_DEVICE_FAILED, "[E_DEVICE_FAILED] Scen on mode configuration failed. Converted from [%s]", GetErrorMessage(r)); } @@ -557,6 +559,7 @@ _CameraImpl::StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo, bool p int tempDisplayHandle = _BufferInfoImpl::INVALID_BUFFER_HANDLE; CameraRotation tempDisplayRotationType = CAMERA_ROTATION_NONE; camera_display_type_e tempDisplayType = ::CAMERA_DISPLAY_TYPE_NONE; + bool previewStarted = false; SysLog(NID_MEDIA, "Camera StartPreview. pBufferInfo:%d, previewedData:%d", (int) pBufferInfo, previewedData); SysTryReturn(NID_MEDIA, __isPoweredOn == true, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Camera is in an invalid state. Camera was not powered on"); @@ -691,6 +694,7 @@ _CameraImpl::StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo, bool p case ::CAMERA_STATE_CAPTURED: r = __pCoordinator->StartMmPreview(); SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] camera start.", GetErrorMessage(r)); + previewStarted = true; break; default: @@ -698,6 +702,12 @@ _CameraImpl::StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo, bool p break; } + if (__sceneMode == CAMERA_SCENE_OFF) + { + r = ReloadConfiguration(_RELOAD_NO_SCEN_MODE_AFTER_PREVIEW); + SysTryCatch(NID_MEDIA, r == E_SUCCESS, r=E_DEVICE_FAILED, E_DEVICE_FAILED, "[E_DEVICE_FAILED] Scen off mode configuration failed. Converted from [%s]", GetErrorMessage(r)); + } + if (previewedData) { __previewProcessing = __previewProcessing | _PREVIEW_POST_PROCESSING; @@ -706,12 +716,15 @@ _CameraImpl::StartPreview(const Tizen::Graphics::BufferInfo* pBufferInfo, bool p { __previewProcessing = __previewProcessing & (~_PREVIEW_POST_PROCESSING); } - - SetState(CAMERA_STATE_PREVIEW); + return r; CATCH: + if (previewStarted) + { + __pCoordinator->StopMmPreview(); + } err = camera_unset_preview_cb(__handle); __previewRegionHandle = _BufferInfoImpl::INVALID_BUFFER_HANDLE; __previewDisplayType = ::CAMERA_DISPLAY_TYPE_NONE; @@ -808,7 +821,7 @@ _CameraImpl::SetBrightness(int brightness) { if(__sceneMode != CAMERA_SCENE_OFF) {//because this attribute is related to scene mode. - r = SetSceneModeOff(_RELOAD_SCEN_MODE_OFF & (~_RELOAD_BRIGHTNESS)); + r = SetSceneModeOff(_RELOAD_NO_SCEN_MODE & (~_RELOAD_BRIGHTNESS)); SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); } operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_BRIGHTNESS : _COP_SECONDARY_BRIGHTNESS); @@ -1129,7 +1142,7 @@ _CameraImpl::SetFlashMode(CameraFlashMode flashMode) if(__sceneMode != CAMERA_SCENE_OFF) {//because this attribute is related to scene mode. - r = SetSceneModeOff(_RELOAD_SCEN_MODE_OFF & (~_RELOAD_FLASH)); + r = SetSceneModeOff(_RELOAD_NO_SCEN_MODE & (~_RELOAD_FLASH)); SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); } r = _CameraUtil::GetMmFlashMode(flashMode, attr); @@ -1212,7 +1225,7 @@ _CameraImpl::SetWhiteBalance(CameraWhiteBalance whiteBalance) if(__sceneMode != CAMERA_SCENE_OFF) {//because this attribute is related to scene mode. - r = SetSceneModeOff(_RELOAD_SCEN_MODE_OFF & (~_RELOAD_WB)); + r = SetSceneModeOff(_RELOAD_NO_SCEN_MODE & (~_RELOAD_WB)); SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); } camera_attr_whitebalance_e attr = ::CAMERA_ATTR_WHITE_BALANCE_NONE; @@ -1296,14 +1309,18 @@ _CameraImpl::SetFocusMode(CameraFocusMode focusMode) , r = E_UNSUPPORTED_TYPE, E_UNSUPPORTED_TYPE, "[E_UNSUPPORTED_TYPE]. This mode(%d) is not supported in the device.\n", focusMode); if(__sceneMode != CAMERA_SCENE_OFF) - {//because this attribute is related to scene mode. - r = SetSceneModeOff(_RELOAD_SCEN_MODE_OFF & (~_RELOAD_FOCUS_MODE)); + { + //because this attribute is related to scene mode. + r = SetSceneModeOff(_RELOAD_NO_SCEN_MODE & (~_RELOAD_FOCUS_MODE)); SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); } - // Set the __focusCallback to false not to call the focus callback in case of CAF. - r = ChangeFocusModeTo(__focusMode, focusMode); - SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. current focus mode is %d, new focus mode is %d", GetErrorMessage(r), __focusMode, focusMode); + if (__state == CAMERA_STATE_PREVIEW) + { + // Set the __focusCallback to false not to call the focus callback in case of CAF. + r = ChangeFocusModeTo(focusMode); + SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. New focus mode is %d", GetErrorMessage(r), focusMode); + } __focusCallback = false; __focusMode = focusMode; @@ -1636,7 +1653,7 @@ _CameraImpl::SetIsoLevel(CameraIsoLevel isoLevel) if(__sceneMode != CAMERA_SCENE_OFF) {//because this attribute is related to scene mode. - r = SetSceneModeOff(_RELOAD_SCEN_MODE_OFF & (~_RELOAD_ISO)); + r = SetSceneModeOff(_RELOAD_NO_SCEN_MODE & (~_RELOAD_ISO)); SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); } r = _CameraUtil::GetMmIso(isoLevel, attr); @@ -1977,7 +1994,7 @@ _CameraImpl::SetMeteringMode(CameraMeteringMode meteringMode) if(__sceneMode != CAMERA_SCENE_OFF) {//because this attribute is related to scene mode. - r = SetSceneModeOff(_RELOAD_SCEN_MODE_OFF & (~_RELOAD_METERING_MODE)); + r = SetSceneModeOff(_RELOAD_NO_SCEN_MODE & (~_RELOAD_METERING_MODE)); SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); } r = _CameraUtil::GetMmMeteringMode(meteringMode, attr); @@ -2027,7 +2044,7 @@ _CameraImpl::SetSceneMode(CameraSceneMode sceneMode) if ((sceneMode == CAMERA_SCENE_OFF) && (__sceneMode != CAMERA_SCENE_OFF)) { - r = SetSceneModeOff(_RELOAD_SCEN_MODE_OFF); + r = SetSceneModeOff(_RELOAD_NO_SCEN_MODE); SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); __sceneMode = CAMERA_SCENE_OFF; } @@ -2736,7 +2753,7 @@ _CameraImpl::ReloadConfiguration(int reload) if ( _CameraCapability::IsSupported(operation)) { - r = ChangeFocusModeTo(__focusMode, __focusMode); + r = ChangeFocusModeTo(__focusMode); SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. focus mode is %d", GetErrorMessage(r), __focusMode); } } @@ -2756,7 +2773,7 @@ _CameraImpl::ReloadConfiguration(int reload) SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. metering:%d", GetErrorMessage(r), __meteringMode); } } - if (reload & _RELOAD_SCENE_MODE_SET) + if (reload & _RELOAD_SCENE_MODE) { _CameraOperationType operation = _COP_NONE; operation = (__selection == CAMERA_PRIMARY ? _COP_PRIMARY_SCENE_MODE : _COP_SECONDARY_SCENE_MODE); @@ -2911,7 +2928,7 @@ _CameraImpl::LoadDefaultConfiguration(int reload) } result -_CameraImpl::ChangeFocusModeTo(CameraFocusMode currentMode, CameraFocusMode destMode) +_CameraImpl::ChangeFocusModeTo(CameraFocusMode focusMode) { result r = E_SUCCESS; int tableTotalCount = 0; @@ -2919,13 +2936,13 @@ _CameraImpl::ChangeFocusModeTo(CameraFocusMode currentMode, CameraFocusMode dest int err = MM_SUCCESS; tableTotalCount = sizeof(_CAMERA_FOCUS_MODE_TRANSIT) / sizeof(_CAMERA_FOCUS_MODE_TRANSIT[0]); - SysLog(NID_MEDIA, " currentMode:%d, destMode:%d, tableTotalCount:%d", currentMode, destMode, tableTotalCount); + SysLog(NID_MEDIA, " currentMode:%d, focusMode:%d, tableTotalCount:%d", __currentFocusMode, focusMode, tableTotalCount); for (i = 0; i < tableTotalCount; i++) { - if (currentMode == _CAMERA_FOCUS_MODE_TRANSIT[i].currentMode && destMode == _CAMERA_FOCUS_MODE_TRANSIT[i].destMode) + if (__currentFocusMode == _CAMERA_FOCUS_MODE_TRANSIT[i].currentMode && focusMode == _CAMERA_FOCUS_MODE_TRANSIT[i].destMode) { - SysLog(NID_MEDIA, "Exist the matching mode field. loop i:%d, current mode:%d, destMode:%d, operation0:%d", i, currentMode, destMode, _CAMERA_FOCUS_MODE_TRANSIT[i].focusOperation0); + SysLog(NID_MEDIA, "Exist the matching mode field. loop i:%d, current mode:%d, focusMode:%d, operation0:%d", i, __currentFocusMode, focusMode, _CAMERA_FOCUS_MODE_TRANSIT[i].focusOperation0); switch (_CAMERA_FOCUS_MODE_TRANSIT[i].focusOperation0) { case _FOCUS_MODE_OP_NONE: @@ -2943,8 +2960,8 @@ _CameraImpl::ChangeFocusModeTo(CameraFocusMode currentMode, CameraFocusMode dest // Set the mm's focus mode. camera_attr_af_mode_e attr = ::CAMERA_ATTR_AF_NONE; - r = _CameraUtil::GetMmFocusMode(destMode, attr); - SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. focus mode:%d", GetErrorMessage(r), destMode); + r = _CameraUtil::GetMmFocusMode(focusMode, attr); + SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. focus mode:%d", GetErrorMessage(r), focusMode); err = camera_attr_set_af_mode (__handle, attr); r = ConvertResult(err); @@ -2968,10 +2985,12 @@ _CameraImpl::ChangeFocusModeTo(CameraFocusMode currentMode, CameraFocusMode dest } } SysTryCatch(NID_MEDIA, i != tableTotalCount, r = E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Not found. "); + + __currentFocusMode = focusMode; return r; CATCH: - SysLog(NID_MEDIA, "[%s] Real currentMode:%d, param destMode:%d", GetErrorMessage(r), currentMode, destMode); + SysLog(NID_MEDIA, "[%s] Real currentMode:%d, param focusMode:%d", GetErrorMessage(r), __currentFocusMode, focusMode); return r; } @@ -3042,12 +3061,12 @@ _CameraImpl::OnCameraCoordinatorModeChanged(_CameraMode mode) if (__sceneMode == CAMERA_SCENE_OFF) { - r = ReloadConfiguration(_RELOAD_SCEN_MODE_OFF); + r = ReloadConfiguration(_RELOAD_NO_SCEN_MODE); SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); } else { - r = ReloadConfiguration(_RELOAD_SCENE_MODE_SET); + r = ReloadConfiguration(_RELOAD_SCENE_MODE); SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Propagating", GetErrorMessage(r)); } diff --git a/src/FMedia_CameraImpl.h b/src/FMedia_CameraImpl.h index 0bfed08..e20406f 100755 --- a/src/FMedia_CameraImpl.h +++ b/src/FMedia_CameraImpl.h @@ -1408,7 +1408,7 @@ private: * @param[in] reload reload configuration field * @exception E_SUCCESS The method is successful. * @exception E_SYSTEM A system error has occurred. - * @remarks Multiple configuration field can be set using reloadConf parameter appending. + * @remarks Multiple configuration field can be set using reload parameter appending. */ result ReloadConfiguration(int reload); @@ -1426,12 +1426,11 @@ private: * Change the focus state. * * @return An error code - * @param[in] currentMode focus' current mode - * @param[in] destMode focus' destinationed mode + * @param[in] focusMode focus' destinationed mode * @exception E_SUCCESS The method is successful. * @exception E_SYSTEM A system error has occurred. */ - result ChangeFocusModeTo(CameraFocusMode currentMode, CameraFocusMode destMode); + result ChangeFocusModeTo(CameraFocusMode focusMode); /** * Handle the auto focus operations. @@ -1510,6 +1509,7 @@ private: CameraRotation __previewRotation; int __fps; CameraFocusMode __focusMode; + CameraFocusMode __currentFocusMode; int __previewProcessing; Tizen::Graphics::Rectangle __previewRegionRect; -- 2.7.4