Skip to content

Commit

Permalink
Fix a bunch of AAC encoder issues
Browse files Browse the repository at this point in the history
- Fixed a timeout issue when the close is sent but the component thread does not exit
- Fixed a race condition waiting for stop to complete
- Don't return error from OMX_GetState()

Change-Id: I5ef5d447e7de4a920d2122f21307a2a11d0858cd
  • Loading branch information
James Dong committed Apr 30, 2010
1 parent 21ec5bd commit 44577d1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
5 changes: 3 additions & 2 deletions omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_CompThread.c
Expand Up @@ -231,10 +231,11 @@ void* AACENC_ComponentThread (void* pThreadData)
pComponentPrivate->bPreempted = 0;
}

pComponentPrivate->bLoadedCommandPending = OMX_FALSE;
pComponentPrivate->bLoadedCommandPending = OMX_FALSE;
goto EXIT;
}

}
}
}

EXIT:
Expand Down
31 changes: 13 additions & 18 deletions omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_Utils.c
Expand Up @@ -951,18 +951,16 @@ OMX_U32 AACENCHandleCommand(AACENC_COMPONENT_PRIVATE *pComponentPrivate)

pComponentPrivate->bIsStopping = 1;

if (pComponentPrivate->codecStop_waitingsignal == 0){
pthread_mutex_lock(&pComponentPrivate->codecStop_mutex);
}
eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,
MMCodecControlStop,(void *)pArgs);

if (pComponentPrivate->codecStop_waitingsignal == 0){
pthread_cond_wait(&pComponentPrivate->codecStop_threshold, &pComponentPrivate->codecStop_mutex);
pComponentPrivate->codecStop_waitingsignal = 0;
pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex);
}

pthread_mutex_lock(&pComponentPrivate->codecStop_mutex);
while (pComponentPrivate->codecStop_waitingsignal == 0){
pthread_cond_wait(&pComponentPrivate->codecStop_threshold, &pComponentPrivate->codecStop_mutex);
}
pComponentPrivate->codecStop_waitingsignal = 0;
pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex);

if(eError != OMX_ErrorNone)
{
OMX_ERROR4(pComponentPrivate->dbg, "%d: Error Occurred in Codec Stop..\n",__LINE__);
Expand Down Expand Up @@ -1467,18 +1465,15 @@ OMX_U32 AACENCHandleCommand(AACENC_COMPONENT_PRIVATE *pComponentPrivate)
pComponentPrivate->bNoIdleOnStop = OMX_TRUE;
OMX_PRINT2(pComponentPrivate->dbg, "AACENC: About to stop socket node line %d\n",__LINE__);

pComponentPrivate->bIsStopping = 1;
if (pComponentPrivate->codecStop_waitingsignal == 0){
pthread_mutex_lock(&pComponentPrivate->codecStop_mutex);
}
pComponentPrivate->bIsStopping = 1;
eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,
MMCodecControlStop,(void *)pArgs);

if (pComponentPrivate->codecStop_waitingsignal == 0){
pthread_mutex_lock(&pComponentPrivate->codecStop_mutex);
while (pComponentPrivate->codecStop_waitingsignal == 0){
pthread_cond_wait(&pComponentPrivate->codecStop_threshold, &pComponentPrivate->codecStop_mutex);
pComponentPrivate->codecStop_waitingsignal = 0;
pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex);
}
pComponentPrivate->codecStop_waitingsignal = 0;
pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex);
}
}
}
Expand Down Expand Up @@ -2625,7 +2620,7 @@ pHandle = pComponentPrivate_CC->pHandle;

pthread_mutex_lock(&pComponentPrivate_CC->codecStop_mutex);
if(pComponentPrivate_CC->codecStop_waitingsignal == 0){
pComponentPrivate_CC->codecStop_waitingsignal = 1;
pComponentPrivate_CC->codecStop_waitingsignal = 1;
pthread_cond_signal(&pComponentPrivate_CC->codecStop_threshold);
OMX_PRINT2(pComponentPrivate_CC->dbg, "stop ack. received. stop waiting for sending disable command completed\n");
}
Expand Down
3 changes: 2 additions & 1 deletion omx/audio/src/openmax_il/aac_enc/src/OMX_AacEncoder.c
Expand Up @@ -1458,7 +1458,8 @@ static OMX_ERRORTYPE GetState (OMX_HANDLETYPE hComponent, OMX_STATETYPE* pState)
else if(ret == ETIMEDOUT) {
/* Unlock mutex in case of timeout */
pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest);
return OMX_ErrorTimeout;
*pState = OMX_StateInvalid;
return OMX_ErrorNone;
}
}
}
Expand Down

0 comments on commit 44577d1

Please sign in to comment.