diff options
-rw-r--r-- | camera/AppCallbackNotifier.cpp | 25 | ||||
-rw-r--r-- | camera/CameraHal.cpp | 2 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXCameraAdapter.cpp | 106 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXCapture.cpp | 31 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXFocus.cpp | 17 | ||||
-rw-r--r-- | camera/inc/OMXCameraAdapter/OMXCameraAdapter.h | 1 |
6 files changed, 150 insertions, 32 deletions
diff --git a/camera/AppCallbackNotifier.cpp b/camera/AppCallbackNotifier.cpp index b737c75..9ff7946 100644 --- a/camera/AppCallbackNotifier.cpp +++ b/camera/AppCallbackNotifier.cpp @@ -174,12 +174,13 @@ void AppCallbackNotifier::errorNotify(int error) CAMHAL_LOGEB("AppCallbackNotifier received error %d", error); - ///Notify errors to application in callback thread. Post error event to event queue - TIUTILS::Message msg; - msg.command = AppCallbackNotifier::NOTIFIER_CMD_PROCESS_ERROR; - msg.arg1 = (void*)error; - - mEventQ.put(&msg); + if ( ( NULL != mCameraHal ) && + ( NULL != mNotifyCb ) && + ( mCameraHal->msgTypeEnabled(CAMERA_MSG_ERROR) ) ) + { + CAMHAL_LOGEB("AppCallbackNotifier mNotifyCb %d", error); + mNotifyCb(CAMERA_MSG_ERROR, CAMERA_ERROR_UNKNOWN, 0, mCallbackCookie); + } LOG_FUNCTION_NAME_EXIT; } @@ -340,18 +341,6 @@ void AppCallbackNotifier::notifyEvent() } break; - - case AppCallbackNotifier::NOTIFIER_CMD_PROCESS_ERROR: - - if ( ( NULL != mCameraHal ) && - ( NULL != mNotifyCb ) && - ( mCameraHal->msgTypeEnabled(CAMERA_MSG_ERROR) ) ) - { - mNotifyCb(CAMERA_MSG_ERROR, CAMERA_ERROR_UNKNOWN, 0, mCallbackCookie); - } - - break; - } if ( NULL != evt ) diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp index 10b8716..089768a 100644 --- a/camera/CameraHal.cpp +++ b/camera/CameraHal.cpp @@ -1503,7 +1503,7 @@ status_t CameraHal::startPreview() mCameraAdapter->sendCommand(CameraAdapter::CAMERA_STOP_PREVIEW); if(mDisplayAdapter.get() != NULL) { - mDisplayAdapter->disableDisplay(); + mDisplayAdapter->disableDisplay(false); } mAppCallbackNotifier->stop(); mPreviewStartInProgress = false; diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp index 0d05b28..79a42d9 100644 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp @@ -45,7 +45,6 @@ namespace android { static OMXCameraAdapter *gCameraAdapter = NULL; Mutex gAdapterLock; - /*--------------------Camera Adapter Class STARTS here-----------------------------*/ status_t OMXCameraAdapter::initialize(CameraProperties::Properties* caps, int sensor_index) @@ -161,6 +160,14 @@ status_t OMXCameraAdapter::initialize(CameraProperties::Properties* caps, int se //Wait for the port enable event to occur ret = mInitSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after Enable Preview Port Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("-Port enable event arrived"); @@ -1071,6 +1078,14 @@ status_t OMXCameraAdapter::flushBuffers() ///Wait for the FLUSH event to occur ret = mFlushSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after Flush Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("Flush event received"); @@ -1217,6 +1232,13 @@ status_t OMXCameraAdapter::UseBuffersPreviewData(void* bufArr, int num) { ret = mUsePreviewDataSem.WaitTimeout(OMX_CMD_TIMEOUT); + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after measurement port enable Exitting!!!"); + return EINVAL; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("Port enable event arrived on measurement port"); @@ -1246,9 +1268,9 @@ status_t OMXCameraAdapter::switchToLoaded() LOG_FUNCTION_NAME; - if ( mComponentState == OMX_StateLoaded ) + if ( mComponentState == OMX_StateLoaded || mComponentState == OMX_StateInvalid) { - CAMHAL_LOGDA("Already in OMX_Loaded state"); + CAMHAL_LOGDA("Already in OMX_Loaded state or OMX_StateInvalid state"); goto EXIT; } @@ -1289,6 +1311,14 @@ status_t OMXCameraAdapter::switchToLoaded() CAMHAL_LOGDA("EXECUTING->IDLE state changed"); ret = mSwitchToLoadedSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after EXECUTING->IDLE Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("EXECUTING->IDLE state changed"); @@ -1332,6 +1362,14 @@ status_t OMXCameraAdapter::switchToLoaded() CAMHAL_LOGDA("Switching IDLE->LOADED state"); ret = mSwitchToLoadedSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after IDLE->LOADED Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("IDLE->LOADED state changed"); @@ -1375,6 +1413,14 @@ status_t OMXCameraAdapter::switchToLoaded() CAMHAL_LOGDA("Enabling Preview port"); ///Wait for state to switch to idle ret = mSwitchToLoadedSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after Enabling Preview port Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("Preview port enabled!"); @@ -1646,6 +1692,14 @@ status_t OMXCameraAdapter::UseBuffersPreview(void* bufArr, int num) CAMHAL_LOGDA("Registering preview buffers"); ret = mUsePreviewSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after Registering preview buffers Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("Preview buffer registration successfull"); @@ -1736,6 +1790,14 @@ status_t OMXCameraAdapter::startPreview() CAMHAL_LOGDA("+Waiting for component to go into EXECUTING state"); ret = mStartPreviewSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after IDLE_EXECUTING Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("+Great. Component went into executing state!!"); @@ -1917,6 +1979,14 @@ status_t OMXCameraAdapter::stopPreview() CAMHAL_LOGDA("Disabling preview port"); ret = mStopPreviewSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after Disabling preview port Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("Preview port disabled"); @@ -2454,6 +2524,29 @@ OMX_ERRORTYPE OMXCameraAdapter::OMXCameraAdapterEventHandler(OMX_IN OMX_HANDLETY { CAMHAL_LOGEA("***Got Fatal Error Notification***\n"); mComponentState = OMX_StateInvalid; + /* + Remove any unhandled events and + unblock any waiting semaphores + */ + if ( !mEventSignalQ.isEmpty() ) + { + for (int i = 0 ; i < mEventSignalQ.size(); i++ ) + { + CAMHAL_LOGEB("***Removing %d EVENTS***** \n", mEventSignalQ.size()); + //remove from queue and free msg + TIUTILS::Message *msg = mEventSignalQ.itemAt(i); + if ( NULL != msg ) + { + Semaphore *sem = (Semaphore*) msg->arg3; + mEventSignalQ.removeAt(i); + if ( sem ) + { + sem->Signal(); + } + free(msg); + } + } + } ///Report Error to App mErrorNotifier->errorNotify(CAMERA_ERROR_UNKNOWN); } @@ -3076,7 +3169,7 @@ bool OMXCameraAdapter::OMXCallbackHandler::Handler() return false; } -OMXCameraAdapter::OMXCameraAdapter():mComponentState (OMX_StateInvalid) +OMXCameraAdapter::OMXCameraAdapter():mComponentState (OMX_StateLoaded) { LOG_FUNCTION_NAME; @@ -3134,10 +3227,13 @@ OMXCameraAdapter::~OMXCameraAdapter() { TIUTILS::Message *msg = mEventSignalQ.itemAt(i); //remove from queue and free msg - mEventSignalQ.removeAt(i); if ( NULL != msg ) { + Semaphore *sem = (Semaphore*) msg->arg3; + mEventSignalQ.removeAt(i); + sem->Signal(); free(msg); + } } } diff --git a/camera/OMXCameraAdapter/OMXCapture.cpp b/camera/OMXCameraAdapter/OMXCapture.cpp index 6626e2f..02cabc4 100644 --- a/camera/OMXCameraAdapter/OMXCapture.cpp +++ b/camera/OMXCameraAdapter/OMXCapture.cpp @@ -798,6 +798,13 @@ status_t OMXCameraAdapter::startImageCapture() ret = mStartCaptureSem.WaitTimeout(OMX_CAPTURE_TIMEOUT); } + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after Image Capture Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("Shutter callback received"); @@ -883,6 +890,14 @@ status_t OMXCameraAdapter::stopImageCapture() //Wait here for the capture to be done, in worst case timeout and proceed with cleanup ret = mCaptureSem.WaitTimeout(OMX_CAPTURE_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State Image Capture Stop Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR != ret ) { ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, @@ -938,6 +953,14 @@ status_t OMXCameraAdapter::stopImageCapture() CAMHAL_LOGDA("Waiting for port disable"); //Wait for the image port enable event ret = mStopCaptureSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after Disable Image Port Exitting!!!"); + goto EXIT; + } + if ( NO_ERROR == ret ) { CAMHAL_LOGDA("Port disabled"); } else { @@ -1060,6 +1083,14 @@ status_t OMXCameraAdapter::UseBuffersCapture(void* bufArr, int num) //Wait for the image port enable event CAMHAL_LOGDA("Waiting for port enable"); ret = mUseCaptureSem.WaitTimeout(OMX_CMD_TIMEOUT); + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after Enable Image Port Exitting!!!"); + goto EXIT; + } + if ( ret == NO_ERROR ) { CAMHAL_LOGDA("Port enabled"); diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp index f7e781e..0482aa8 100644 --- a/camera/OMXCameraAdapter/OMXFocus.cpp +++ b/camera/OMXCameraAdapter/OMXFocus.cpp @@ -146,14 +146,17 @@ status_t OMXCameraAdapter::doAutoFocus() if ( ( focusControl.eFocusControl != OMX_IMAGE_FocusControlAuto ) && ( focusControl.eFocusControl != ( OMX_IMAGE_FOCUSCONTROLTYPE ) OMX_IMAGE_FocusControlAutoInfinity ) ) { - //ret = mDoAFSem.WaitTimeout(AF_CALLBACK_TIMEOUT); - //Disable auto focus callback from Ducati - //setFocusCallback(false); - //Signal a dummy AF event so that in case the callback from ducati - //does come then it doesnt crash after - //exiting this function since eventSem will go out of scope. + if(mDoAFSem.WaitTimeout(AF_CALLBACK_TIMEOUT) != NO_ERROR) { - //Disable auto focus callback from Ducati + + //If somethiing bad happened while we wait + if (mComponentState == OMX_StateInvalid) + { + CAMHAL_LOGEA("Invalid State after Auto Focus Exitting!!!"); + return EINVAL; + } + + //Disable auto focus callback from Ducati setFocusCallback(false); CAMHAL_LOGEA("Autofocus callback timeout expired"); RemoveEvent(mCameraAdapterParameters.mHandleComp, diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h index a29095d..b7d7f2d 100644 --- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h +++ b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h @@ -50,7 +50,6 @@ namespace android { #define Q16_OFFSET 16 #define OMX_CMD_TIMEOUT 3000000 //3 sec. -#define AF_CALLBACK_TIMEOUT 10000000 //10 seconds timeout #define OMX_CAPTURE_TIMEOUT 5000000 //5 sec. #define FOCUS_THRESHOLD 5 //[s.] |