summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-05-19 17:14:46 -0700
committerJames Dong <jdong@google.com>2010-05-24 16:56:37 -0700
commitb01194f357cd5bc2cdad578ac6431640ff3fb148 (patch)
tree9dd9083818073b4e3523ab7f1c1948c696bbbe7b
parent27bb904e35a755c541302d014f2b3ddaa3dfb7cb (diff)
downloadomap3-b01194f357cd5bc2cdad578ac6431640ff3fb148.tar.gz
OMX_GetState() always timeout after OMX_StateIdle to OMX_StateLoaded transition.
The timeout duration is 3 seconds, which slows down the shutdown of the audio omx encoder component - bug 2711318 - AMRNB part Change-Id: I18c80fa2b5e4ea89589231a7bb2254b6579c7a05
-rw-r--r--omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_ComponentThread.c22
-rw-r--r--omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_Utils.c29
-rw-r--r--omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEncoder.c55
3 files changed, 42 insertions, 64 deletions
diff --git a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_ComponentThread.c b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_ComponentThread.c
index b189ea6..8830f69 100644
--- a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_ComponentThread.c
+++ b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_ComponentThread.c
@@ -198,12 +198,18 @@ void* NBAMRENC_CompThread(void* pThreadData)
#endif
if(pComponentPrivate->bPreempted==0){
- pComponentPrivate->cbInfo.EventHandler( pHandle,
- pHandle->pApplicationPrivate,
- OMX_EventCmdComplete,
- OMX_ErrorNone,
- pComponentPrivate->curState,
- NULL);
+
+ if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) {
+ return OMX_ErrorUndefined;
+ }
+
+ pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
+ pComponentPrivate->pHandle->pApplicationPrivate,
+ OMX_EventCmdComplete,
+ OMX_CommandStateSet,
+ pComponentPrivate->curState,
+ NULL);
+
}
else{
pComponentPrivate->cbInfo.EventHandler( pHandle,
@@ -214,9 +220,7 @@ void* NBAMRENC_CompThread(void* pThreadData)
NULL);
pComponentPrivate->bPreempted = 0;
}
-
-
-
+ goto EXIT;
}
}
diff --git a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_Utils.c b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_Utils.c
index 5fa42c2..a8f4194 100644
--- a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_Utils.c
+++ b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_Utils.c
@@ -1160,15 +1160,12 @@ OMX_U32 NBAMRENC_HandleCommand (AMRENC_COMPONENT_PRIVATE *pComponentPrivate)
if (pComponentPrivate->pInputBufferList->numBuffers ||
pComponentPrivate->pOutputBufferList->numBuffers) {
- pthread_mutex_lock(&pComponentPrivate->ToLoaded_mutex);
+ pthread_mutex_lock(&pComponentPrivate->InIdle_mutex);
pComponentPrivate->InIdle_goingtoloaded = 1;
+ pthread_cond_wait(&pComponentPrivate->InIdle_threshold, &pComponentPrivate->InIdle_mutex);
pthread_mutex_unlock(&pComponentPrivate->ToLoaded_mutex);
-
}
- if (!pComponentPrivate->pInputBufferList->numBuffers &&
- !pComponentPrivate->pOutputBufferList->numBuffers) {
-
/* Now Deinitialize the component No error should be returned from
* this function. It should clean the system as much as possible */
NBAMRENC_CleanupInitParams(pComponentPrivate->pHandle);
@@ -1179,13 +1176,13 @@ OMX_U32 NBAMRENC_HandleCommand (AMRENC_COMPONENT_PRIVATE *pComponentPrivate)
goto EXIT;
}
- /*Closing LCML Lib*/
- if (pComponentPrivate->ptrLibLCML != NULL)
- {
- OMX_PRDSP2(pComponentPrivate->dbg, "%d OMX_AmrEncoder.c Closing LCML library\n",__LINE__);
- dlclose( pComponentPrivate->ptrLibLCML);
- pComponentPrivate->ptrLibLCML = NULL;
- }
+ /*Closing LCML Lib*/
+ if (pComponentPrivate->ptrLibLCML != NULL)
+ {
+ OMX_PRDSP2(pComponentPrivate->dbg, "%d OMX_AmrEncoder.c Closing LCML library\n",__LINE__);
+ dlclose( pComponentPrivate->ptrLibLCML);
+ pComponentPrivate->ptrLibLCML = NULL;
+ }
#ifdef __PERF_INSTRUMENTATION__
@@ -1195,12 +1192,6 @@ OMX_U32 NBAMRENC_HandleCommand (AMRENC_COMPONENT_PRIVATE *pComponentPrivate)
pComponentPrivate->bInitParamsInitialized = 0;
pComponentPrivate->bLoadedCommandPending = OMX_FALSE;
pComponentPrivate->bLoadedWaitingFreeBuffers = OMX_FALSE;
-
- }
- else {
- pComponentPrivate->bLoadedWaitingFreeBuffers = OMX_TRUE;
- OMX_PRBUFFER2(pComponentPrivate->dbg, "Skipped this section because buffers not yet freed\n");
- }
break;
case OMX_StatePause:
@@ -3209,6 +3200,7 @@ OMX_ERRORTYPE AddStateTransition(AMRENC_COMPONENT_PRIVATE *pComponentPrivate) {
}
/* Increment state change request reference count */
pComponentPrivate->nPendingStateChangeRequests++;
+ LOGI("addstatetranstion: %ld @ %d", pComponentPrivate->nPendingStateChangeRequests, pComponentPrivate->curState);
if(pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest)) {
return OMX_ErrorUndefined;
@@ -3225,6 +3217,7 @@ OMX_ERRORTYPE RemoveStateTransition(AMRENC_COMPONENT_PRIVATE *pComponentPrivate,
}
pComponentPrivate->nPendingStateChangeRequests--;
+ LOGI("removestatetransition: %ld @ %d", pComponentPrivate->nPendingStateChangeRequests, pComponentPrivate->curState);
/* If there are no more pending requests, signal the thread waiting on this*/
if(!pComponentPrivate->nPendingStateChangeRequests && bEnableSignal) {
pthread_cond_signal(&(pComponentPrivate->StateChangeCondition));
diff --git a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEncoder.c b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEncoder.c
index db06645..a7fc638 100644
--- a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEncoder.c
+++ b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEncoder.c
@@ -1480,39 +1480,25 @@ static OMX_ERRORTYPE GetState (OMX_HANDLETYPE pComponent, OMX_STATETYPE* pState)
/* Retrieve current state */
if (pHandle && pHandle->pComponentPrivate) {
/* Check for any pending state transition requests */
- if(pthread_mutex_lock(&pComponentPrivate->mutexStateChangeRequest)) {
- return OMX_ErrorUndefined;
- }
- nPendingStateChangeRequests = pComponentPrivate->nPendingStateChangeRequests;
- if(!nPendingStateChangeRequests) {
- if(pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest)) {
- return OMX_ErrorUndefined;
- }
-
- /* No pending state transitions */
- *pState = ((AMRENC_COMPONENT_PRIVATE*)pHandle->pComponentPrivate)->curState;
- eError = OMX_ErrorNone;
- }
- else {
+ pthread_mutex_lock(&pComponentPrivate->mutexStateChangeRequest);
+ while (pComponentPrivate->nPendingStateChangeRequests != 0) {
/* Wait for component to complete state transition */
clock_gettime(CLOCK_REALTIME, &abs_time);
abs_time.tv_sec += mutex_timeout;
abs_time.tv_nsec = 0;
- ret = pthread_cond_timedwait(&(pComponentPrivate->StateChangeCondition), &(pComponentPrivate->mutexStateChangeRequest), &abs_time);
- if (!ret) {
- /* Component has completed state transitions*/
- *pState = ((AMRENC_COMPONENT_PRIVATE*)pHandle->pComponentPrivate)->curState;
- if(pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest)) {
- return OMX_ErrorUndefined;
- }
- eError = OMX_ErrorNone;
- }
- else if(ret == ETIMEDOUT) {
- /* Unlock mutex in case of timeout */
- pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest);
- return OMX_ErrorTimeout;
+ ret = pthread_cond_timedwait(&(pComponentPrivate->StateChangeCondition),
+ &(pComponentPrivate->mutexStateChangeRequest), &abs_time);
+ if (ret == ETIMEDOUT) {
+ OMX_ERROR4(pComponentPrivate->dbg, "GetState() timeout at state %d",
+ pComponentPrivate->curState);
+ *pState = OMX_StateInvalid;
+ break;
}
}
+ if (!ret) {
+ *pState = pComponentPrivate->curState;
+ }
+ pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest);
}
else {
eError = OMX_ErrorInvalidComponent;
@@ -2130,9 +2116,9 @@ static OMX_ERRORTYPE FreeBuffer(
!pComponentPrivate->pOutputBufferList->numBuffers) &&
pComponentPrivate->InIdle_goingtoloaded)
{
- pComponentPrivate->InIdle_goingtoloaded = 0;
#ifndef UNDER_CE
pthread_mutex_lock(&pComponentPrivate->InIdle_mutex);
+ pComponentPrivate->InIdle_goingtoloaded = 0;
pthread_cond_signal(&pComponentPrivate->InIdle_threshold);
pthread_mutex_unlock(&pComponentPrivate->InIdle_mutex);
#else
@@ -2140,16 +2126,11 @@ static OMX_ERRORTYPE FreeBuffer(
#endif
}
- pthread_mutex_unlock(&pComponentPrivate->ToLoaded_mutex);
-
- if ((pComponentPrivate->bLoadedWaitingFreeBuffers &&(!pComponentPrivate->pInputBufferList->numBuffers &&
- !pComponentPrivate->pOutputBufferList->numBuffers))) {
- OMX_PRCOMM1(pComponentPrivate->dbg, "reissuing loaded command\n");
- SendCommand(pComponentPrivate->pHandle,OMX_CommandStateSet,OMX_StateLoaded,NULL);
- }
-if (pComponentPrivate->bDisableCommandPending && (pComponentPrivate->pInputBufferList->numBuffers + pComponentPrivate->pOutputBufferList->numBuffers == 0)) {
+ pthread_mutex_unlock(&pComponentPrivate->ToLoaded_mutex);
+ if (pComponentPrivate->bDisableCommandPending &&
+ (pComponentPrivate->pInputBufferList->numBuffers + pComponentPrivate->pOutputBufferList->numBuffers == 0)) {
SendCommand (pComponentPrivate->pHandle,OMX_CommandPortDisable,pComponentPrivate->bDisableCommandParam,NULL);
- }
+ }
OMX_PRINT1(pComponentPrivate->dbg, "%d :: Exiting FreeBuffer\n", __LINE__);
OMX_PRINT1(pComponentPrivate->dbg, "%d :: Returning = 0x%x\n",__LINE__,eError);
return eError;