diff options
-rw-r--r-- | camera/OMXCameraAdapter/OMXCameraAdapter.cpp | 62 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXCapture.cpp | 8 | ||||
-rw-r--r-- | camera/OMXCameraAdapter/OMXFocus.cpp | 14 | ||||
-rw-r--r-- | camera/inc/OMXCameraAdapter/OMXCameraAdapter.h | 5 | ||||
-rw-r--r-- | libtiutils/Semaphore.cpp | 6 |
5 files changed, 76 insertions, 19 deletions
diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp index 6211c51..2f32915 100644 --- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp +++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp @@ -167,7 +167,7 @@ status_t OMXCameraAdapter::initialize(CameraProperties::Properties* caps, int se } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandPortEnable, mCameraAdapterParameters.mPrevPortIndex, @@ -1077,7 +1077,7 @@ status_t OMXCameraAdapter::flushBuffers() } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandFlush, OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW, @@ -1223,7 +1223,7 @@ status_t OMXCameraAdapter::UseBuffersPreviewData(void* bufArr, int num) } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandPortEnable, mCameraAdapterParameters.mMeasurementPortIndex, @@ -1295,7 +1295,7 @@ status_t OMXCameraAdapter::switchToLoaded() } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandStateSet, OMX_StateIdle, @@ -1338,7 +1338,7 @@ status_t OMXCameraAdapter::switchToLoaded() } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandStateSet, OMX_StateLoaded, @@ -1381,7 +1381,7 @@ status_t OMXCameraAdapter::switchToLoaded() } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandPortEnable, mCameraAdapterParameters.mPrevPortIndex, @@ -1654,7 +1654,7 @@ status_t OMXCameraAdapter::UseBuffersPreview(void* bufArr, int num) { if ( mComponentState == OMX_StateLoaded ) { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandStateSet, OMX_StateIdle, @@ -1742,7 +1742,7 @@ status_t OMXCameraAdapter::startPreview() } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandStateSet, OMX_StateExecuting, @@ -1923,7 +1923,7 @@ status_t OMXCameraAdapter::stopPreview() } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandPortDisable, mCameraAdapterParameters.mPrevPortIndex, @@ -2543,6 +2543,49 @@ OMX_ERRORTYPE OMXCameraAdapter::SignalEvent(OMX_IN OMX_HANDLETYPE hComponent, return OMX_ErrorNone; } +OMX_ERRORTYPE OMXCameraAdapter::RemoveEvent(OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_EVENTTYPE eEvent, + OMX_IN OMX_U32 nData1, + OMX_IN OMX_U32 nData2, + OMX_IN OMX_PTR pEventData) +{ + Mutex::Autolock lock(mEventLock); + TIUTILS::Message *msg; + LOG_FUNCTION_NAME; + + if ( !mEventSignalQ.isEmpty() ) + { + CAMHAL_LOGDA("Event queue not empty"); + + for ( unsigned int i = 0 ; i < mEventSignalQ.size() ; i++ ) + { + msg = mEventSignalQ.itemAt(i); + if ( NULL != msg ) + { + if( ( msg->command != 0 || msg->command == ( unsigned int ) ( eEvent ) ) + && ( !msg->arg1 || ( OMX_U32 ) msg->arg1 == nData1 ) + && ( !msg->arg2 || ( OMX_U32 ) msg->arg2 == nData2 ) + && msg->arg3) + { + Semaphore *sem = (Semaphore*) msg->arg3; + CAMHAL_LOGDA("Event matched, signalling sem"); + mEventSignalQ.removeAt(i); + free(msg); + break; + } + } + } + } + else + { + CAMHAL_LOGEA("Event queue empty!!!"); + } + LOG_FUNCTION_NAME_EXIT; + + return OMX_ErrorNone; +} + + status_t OMXCameraAdapter::RegisterForEvent(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_EVENTTYPE eEvent, OMX_IN OMX_U32 nData1, @@ -2554,7 +2597,6 @@ status_t OMXCameraAdapter::RegisterForEvent(OMX_IN OMX_HANDLETYPE hComponent, Mutex::Autolock lock(mEventLock); LOG_FUNCTION_NAME; - TIUTILS::Message * msg = ( struct TIUTILS::Message * ) malloc(sizeof(struct TIUTILS::Message)); if ( NULL != msg ) { diff --git a/camera/OMXCameraAdapter/OMXCapture.cpp b/camera/OMXCameraAdapter/OMXCapture.cpp index 6bec221..4e82d3d 100644 --- a/camera/OMXCameraAdapter/OMXCapture.cpp +++ b/camera/OMXCameraAdapter/OMXCapture.cpp @@ -805,7 +805,7 @@ status_t OMXCameraAdapter::startImageCapture() } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, OMX_ALL, OMX_TI_IndexConfigShutterCallback, @@ -871,7 +871,7 @@ 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 ( NO_ERROR != ret ) { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, OMX_ALL, OMX_TI_IndexConfigShutterCallback, @@ -928,7 +928,7 @@ status_t OMXCameraAdapter::stopImageCapture() if ( NO_ERROR == ret ) { CAMHAL_LOGDA("Port disabled"); } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandPortDisable, mCameraAdapterParameters.mImagePortIndex, @@ -1053,7 +1053,7 @@ status_t OMXCameraAdapter::UseBuffersCapture(void* bufArr, int num) } else { - ret |= SignalEvent(mCameraAdapterParameters.mHandleComp, + ret |= RemoveEvent(mCameraAdapterParameters.mHandleComp, OMX_EventCmdComplete, OMX_CommandPortEnable, mCameraAdapterParameters.mImagePortIndex, diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp index 17527af..f57e6ba 100644 --- a/camera/OMXCameraAdapter/OMXFocus.cpp +++ b/camera/OMXCameraAdapter/OMXFocus.cpp @@ -31,7 +31,7 @@ #include "ErrorUtils.h" #define TOUCH_FOCUS_RANGE 0xFF -#define AF_CALLBACK_TIMEOUT 10000000 //10 seconds timeout +#define AF_CALLBACK_TIMEOUT 5000000 //5 seconds timeout namespace android { @@ -146,15 +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); + //ret = mDoAFSem.WaitTimeout(AF_CALLBACK_TIMEOUT); //Disable auto focus callback from Ducati - setFocusCallback(false); + //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(ret != NO_ERROR) { + if(mDoAFSem.WaitTimeout(AF_CALLBACK_TIMEOUT) != NO_ERROR) { + //Disable auto focus callback from Ducati + setFocusCallback(false); CAMHAL_LOGEA("Autofocus callback timeout expired"); - SignalEvent(mCameraAdapterParameters.mHandleComp, + RemoveEvent(mCameraAdapterParameters.mHandleComp, (OMX_EVENTTYPE) OMX_EventIndexSettingChanged, OMX_ALL, OMX_IndexConfigCommonFocusStatus, @@ -162,6 +164,8 @@ status_t OMXCameraAdapter::doAutoFocus() returnFocusStatus(true); } else { CAMHAL_LOGDA("Autofocus callback received"); + //Disable auto focus callback from Ducati + setFocusCallback(false); ret = returnFocusStatus(false); } diff --git a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h index 4f53b7d..771bd0c 100644 --- a/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h +++ b/camera/inc/OMXCameraAdapter/OMXCameraAdapter.h @@ -404,6 +404,11 @@ private: OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData); + OMX_ERRORTYPE RemoveEvent(OMX_IN OMX_HANDLETYPE hComponent, + OMX_IN OMX_EVENTTYPE eEvent, + OMX_IN OMX_U32 nData1, + OMX_IN OMX_U32 nData2, + OMX_IN OMX_PTR pEventData); status_t RegisterForEvent(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_EVENTTYPE eEvent, diff --git a/libtiutils/Semaphore.cpp b/libtiutils/Semaphore.cpp index 1f46dca..41fa99c 100644 --- a/libtiutils/Semaphore.cpp +++ b/libtiutils/Semaphore.cpp @@ -217,6 +217,12 @@ status_t Semaphore::WaitTimeout(int timeoutMicroSecs) ret = sem_timedwait(mSemaphore, &timeSpec);
}
+ if ( NO_ERROR != ret )
+ {
+ Signal();
+ Create(0);
+ }
+
return ret;
}
|