diff options
author | Sundar Raman <sunds@ti.com> | 2011-11-08 11:10:16 -0800 |
---|---|---|
committer | Iliyan Malchev <malchev@google.com> | 2011-11-10 13:48:29 -0800 |
commit | 3ec18006399d61e97382601d14aaa43ee339c8b6 (patch) | |
tree | ebf4a581c181fe06b14e2228c75953934f6c0162 /camera | |
parent | 2136042f80a20aeeef3ece24bab027c401426334 (diff) | |
download | hardware_ti_omap4xxx-3ec18006399d61e97382601d14aaa43ee339c8b6.zip hardware_ti_omap4xxx-3ec18006399d61e97382601d14aaa43ee339c8b6.tar.gz hardware_ti_omap4xxx-3ec18006399d61e97382601d14aaa43ee339c8b6.tar.bz2 |
CameraHAL: Fixes for ANR and a setParameter issue
Fix 1/3 for b/5593964.
1. Ensure we don't race with stopImageCapture when stopPreview is called
2. Signal the shutter callback correctly
3. Do not crash the media server if focus APIs and image capture returns error
Still go ahead and perform de-init
4. Replace setParameter from CameraHAl to AppCallbackNotifier with getParameter
when needed.
Change-Id: I2b2745827d227a8d7927ce1611a84c29129e8891
Signed-off-by: Sundar Raman <sunds@ti.com>
Signed-off-by: Iliyan Malchev <malchev@google.com>
Diffstat (limited to 'camera')
-rw-r--r-- | camera/AppCallbackNotifier.cpp | 42 | ||||
-rw-r--r-- | camera/CameraHal.cpp | 5 | ||||
-rwxr-xr-x | camera/OMXCameraAdapter/OMXCameraAdapter.cpp | 8 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXCapture.cpp | 18 | ||||
-rw-r--r-- | camera/inc/CameraHal.h | 6 |
5 files changed, 42 insertions, 37 deletions
diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp index c716291..4513c48 100644 --- a/camera/AppCallbackNotifier.cpp +++ b/camera/AppCallbackNotifier.cpp @@ -310,7 +310,10 @@ void AppCallbackNotifier::notifyEvent() ///Receive and send the event notifications to app TIUTILS::Message msg; LOG_FUNCTION_NAME; + { + Mutex::Autolock lock(mLock); mEventQ.get(&msg); + } bool ret = true; CameraHalEvent *evt = NULL; CameraHalEvent::FocusEventData *focusEvtData; @@ -820,12 +823,16 @@ void AppCallbackNotifier::notifyFrame() buf = raw_picture->data; } - encode_quality = mParameters.getInt(CameraParameters::KEY_JPEG_QUALITY); + CameraParameters parameters; + const String8 strParams(mCameraHal->getParameters()); + parameters.unflatten(strParams); + + encode_quality = parameters.getInt(CameraParameters::KEY_JPEG_QUALITY); if (encode_quality < 0 || encode_quality > 100) { encode_quality = 100; } - tn_quality = mParameters.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY); + tn_quality = parameters.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY); if (tn_quality < 0 || tn_quality > 100) { tn_quality = 100; } @@ -849,8 +856,8 @@ void AppCallbackNotifier::notifyFrame() main_jpeg->format = CameraParameters::PIXEL_FORMAT_YUV422I; } - tn_width = mParameters.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); - tn_height = mParameters.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); + tn_width = parameters.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH); + tn_height = parameters.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT); if ((tn_width > 0) && (tn_height > 0)) { tn_jpeg = (Encoder_libjpeg::params*) @@ -863,7 +870,7 @@ void AppCallbackNotifier::notifyFrame() if (tn_jpeg) { int width, height; - mParameters.getPreviewSize(&width,&height); + parameters.getPreviewSize(&width,&height); current_snapshot = (mPreviewBufCount + MAX_BUFFERS - 1) % MAX_BUFFERS; tn_jpeg->src = (uint8_t*) mPreviewBufs[current_snapshot]; tn_jpeg->src_size = mPreviewMemory->size / MAX_BUFFERS; @@ -1140,8 +1147,11 @@ void AppCallbackNotifier::eventCallback(CameraHalEvent* chEvt) { msg.command = AppCallbackNotifier::NOTIFIER_CMD_PROCESS_EVENT; msg.arg1 = event; + { + Mutex::Autolock lock(mLock); mEventQ.put(&msg); } + } else { CAMHAL_LOGEA("Not enough resources to allocate CameraHalEvent"); @@ -1153,6 +1163,18 @@ void AppCallbackNotifier::eventCallback(CameraHalEvent* chEvt) } +void AppCallbackNotifier::flushEventQueue() +{ + + { + Mutex::Autolock lock(mLock); + TIUTILS::Message msg; + while(!mEventQ.isEmpty()) + mEventQ.get(&msg); + } +} + + bool AppCallbackNotifier::processMessage() { ///Retrieve the command from the command queue and process it @@ -1418,16 +1440,6 @@ void AppCallbackNotifier::setVideoRes(int width, int height) LOG_FUNCTION_NAME_EXIT; } -int AppCallbackNotifier::setParameters(const CameraParameters& params) -{ - LOG_FUNCTION_NAME; - - mParameters = params; - - LOG_FUNCTION_NAME_EXIT; - return NO_ERROR; -} - status_t AppCallbackNotifier::stopPreviewCallbacks() { sp<MemoryHeapBase> heap; diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp index 1f14a2e..7e18330 100644 --- a/camera/CameraHal.cpp +++ b/camera/CameraHal.cpp @@ -1008,10 +1008,6 @@ int CameraHal::setParameters(const CameraParameters& params) mParameters.unflatten(oldParams.flatten()); } - if ( NULL != mAppCallbackNotifier.get() ) { - mAppCallbackNotifier->setParameters(mParameters); - } - // Restart Preview if needed by KEY_RECODING_HINT only if preview is already running. // If preview is not started yet, Video Mode parameters will take effect on next startPreview() if (restartPreviewRequired && previewEnabled() && !mRecordingEnabled) { @@ -2222,6 +2218,7 @@ status_t CameraHal::cancelAutoFocus() adapterParams.set(TICameraParameters::KEY_AUTO_FOCUS_LOCK, CameraParameters::FALSE); mCameraAdapter->setParameters(adapterParams); mCameraAdapter->sendCommand(CameraAdapter::CAMERA_CANCEL_AUTOFOCUS); + mAppCallbackNotifier->flushEventQueue(); } LOG_FUNCTION_NAME_EXIT; diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp index e97244c..2268e44 100755 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp @@ -3331,14 +3331,6 @@ bool OMXCameraAdapter::CommandHandler::Handler() } } - if ( NO_ERROR != stat ) - { - errorNotify = ( ErrorNotifier * ) msg.arg1; - if ( NULL != errorNotify ) - { - errorNotify->errorNotify(CAMERA_ERROR_HARD); - } - } } LOG_FUNCTION_NAME_EXIT; diff --git a/camera/OMXCameraAdapter/OMXCapture.cpp b/camera/OMXCameraAdapter/OMXCapture.cpp index 68111b8..9ba438c 100644 --- a/camera/OMXCameraAdapter/OMXCapture.cpp +++ b/camera/OMXCameraAdapter/OMXCapture.cpp @@ -741,6 +741,11 @@ status_t OMXCameraAdapter::startImageCapture() return NO_INIT; } + if ((getNextState() & (CAPTURE_ACTIVE|BRACKETING_ACTIVE)) == 0) { + CAMHAL_LOGDA("trying starting capture when already canceled"); + return NO_ERROR; + } + // Camera framework doesn't expect face callbacks once capture is triggered pauseFaceDetection(true); @@ -899,12 +904,13 @@ status_t OMXCameraAdapter::stopImageCapture() // if anybody is waiting on the shutter callback // signal them and then recreate the semaphore if ( 0 != mStartCaptureSem.Count() ) { - for (int i = mStopCaptureSem.Count(); i > 0; i--) { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, - (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, - OMX_ALL, - OMX_TI_IndexConfigShutterCallback, - NULL ); + + for (int i = mStartCaptureSem.Count(); i < 0; i++) { + ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, + OMX_ALL, + OMX_TI_IndexConfigShutterCallback, + NULL ); } mStartCaptureSem.Create(0); } diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h index c6af5ab..f33515a 100644 --- a/camera/inc/CameraHal.h +++ b/camera/inc/CameraHal.h @@ -566,8 +566,6 @@ public: //Set Burst mode void setBurst(bool burst); - int setParameters(const CameraParameters& params); - //Notifications from CameraHal for video recording case status_t startRecording(); status_t stopRecording(); @@ -583,6 +581,8 @@ public: bool getUesVideoBuffers(); void setVideoRes(int width, int height); + void flushEventQueue(); + //Internal class definitions class NotificationThread : public Thread { AppCallbackNotifier* mAppCallbackNotifier; @@ -662,8 +662,6 @@ private: bool mUseMetaDataBufferMode; bool mRawAvailable; - CameraParameters mParameters; - bool mUseVideoBuffers; int mVideoWidth; |