diff options
author | James Dong <jdong@google.com> | 2010-05-25 15:46:55 -0700 |
---|---|---|
committer | James Dong <jdong@google.com> | 2010-05-25 16:02:20 -0700 |
commit | a7ccfa60eb59833acbd1d6f549cb16fce006a27b (patch) | |
tree | 0226f3b94d64dcc15ded46636aad91054e34f9b4 | |
parent | b01194f357cd5bc2cdad578ac6431640ff3fb148 (diff) | |
download | omap3-a7ccfa60eb59833acbd1d6f549cb16fce006a27b.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 - Final part: AMRWB and AAC encoders
Change-Id: Id09961d8bc96b03955af0141a0a12544bfd80897
6 files changed, 49 insertions, 67 deletions
diff --git a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_CompThread.c b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_CompThread.c index 655fd25..e124702 100644 --- a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_CompThread.c +++ b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_CompThread.c @@ -212,12 +212,15 @@ void* AACENC_ComponentThread (void* pThreadData) PERF_Boundary(pComponentPrivate->pPERFcomp,PERF_BoundaryComplete | PERF_BoundaryCleanup); #endif - if(pComponentPrivate->bPreempted==0){ - pComponentPrivate->cbInfo.EventHandler(pHandle, + if (RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { + return OMX_ErrorUndefined; + } + pComponentPrivate->cbInfo.EventHandler(pHandle, pHandle->pApplicationPrivate, OMX_EventCmdComplete, - OMX_ErrorNone,pComponentPrivate->curState, + OMX_CommandStateSet, + pComponentPrivate->curState, NULL); } diff --git a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_Utils.c b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_Utils.c index 85f79c7..eac1201 100644 --- a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_Utils.c +++ b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_Utils.c @@ -3455,6 +3455,7 @@ OMX_ERRORTYPE AddStateTransition(AACENC_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; @@ -3470,6 +3471,7 @@ OMX_ERRORTYPE RemoveStateTransition(AACENC_COMPONENT_PRIVATE* pComponentPrivate, return OMX_ErrorUndefined; } pComponentPrivate->nPendingStateChangeRequests--; + LOGI("removestatetranstion: %ld @ %d", pComponentPrivate->nPendingStateChangeRequests, pComponentPrivate->curState); /* If there are no more pending requests, signal the thread waiting on this*/ if(!pComponentPrivate->nPendingStateChangeRequests && bEnableSignal) { diff --git a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEncoder.c b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEncoder.c index 845c565..e7feea1 100644 --- a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEncoder.c +++ b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEncoder.c @@ -1428,40 +1428,26 @@ static OMX_ERRORTYPE GetState (OMX_HANDLETYPE hComponent, 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 = ((AACENC_COMPONENT_PRIVATE*)pHandle->pComponentPrivate)->curState; - eError = OMX_ErrorNone; - } - else { - /* Wait for component to complete state transition */ + pthread_mutex_lock(&pComponentPrivate->mutexStateChangeRequest); + while (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 = ((AACENC_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); - *pState = OMX_StateInvalid; - return OMX_ErrorNone; + 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; diff --git a/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_CompThread.c b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_CompThread.c index 4cac76e..3257633 100644 --- a/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_CompThread.c +++ b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_CompThread.c @@ -204,10 +204,14 @@ void* WBAMRENC_CompThread(void* pThreadData) { #endif if (pComponentPrivate->bPreempted == 0) { + if(RemoveStateTransition(pComponentPrivate, OMX_TRUE) != OMX_ErrorNone) { + return OMX_ErrorUndefined; + } + pComponentPrivate->cbInfo.EventHandler( pHandle, pHandle->pApplicationPrivate, OMX_EventCmdComplete, - OMX_ErrorNone, + OMX_CommandStateSet, pComponentPrivate->curState, NULL); } else { diff --git a/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_Utils.c b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_Utils.c index 8713be8..9848241 100644 --- a/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_Utils.c +++ b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_Utils.c @@ -3426,6 +3426,8 @@ OMX_ERRORTYPE AddStateTransition(WBAMRENC_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; } @@ -3443,6 +3445,7 @@ OMX_ERRORTYPE RemoveStateTransition(WBAMRENC_COMPONENT_PRIVATE* pComponentPrivat pComponentPrivate->nPendingStateChangeRequests--; + LOGI("removestatetranstion: %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/wbamr_enc/src/OMX_WbAmrEncoder.c b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEncoder.c index c282add..7fc1b8d 100644 --- a/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEncoder.c +++ b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEncoder.c @@ -1558,42 +1558,26 @@ static OMX_ERRORTYPE GetState (OMX_HANDLETYPE hComponent, 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 = ((WBAMRENC_COMPONENT_PRIVATE*)pHandle->pComponentPrivate)->curState; - eError = OMX_ErrorNone; - } - else { - /* Wait for component to complete state transition */ - clock_gettime(CLOCK_REALTIME, &abs_time); - abs_time.tv_sec += mutex_timeout; + 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 = ((WBAMRENC_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; + } } - } - else { + if (!ret) { + *pState = pComponentPrivate->curState; + } + pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest); + } else { eError = OMX_ErrorInvalidComponent; *pState = OMX_StateInvalid; } |