diff options
author | Masaki Sato <masaki.sato@motorola.com> | 2009-09-15 13:36:56 -0500 |
---|---|---|
committer | James Dong <jdong@google.com> | 2009-09-16 21:22:20 -0700 |
commit | c024b9e6872263b80017da0d169e9fbd790b2051 (patch) | |
tree | 6a81c714f8190423a21f09c148e3a3c094adcb4d /omx | |
parent | 5e0e7a0a915ca0a359dc7bdb6cf2eacbf9fcbb45 (diff) | |
download | omap3-c024b9e6872263b80017da0d169e9fbd790b2051.tar.gz |
Fixes the issue where AAC OMX decoder component doesn't
return all the buffers when the state transition from
executing to idle is completed.
bug 2055525
Originally from: https://partner.source.android.com/g/#change,1056
Diffstat (limited to 'omx')
-rw-r--r-- | omx/audio/src/openmax_il/aac_dec/inc/OMX_AacDec_Utils.h | 23 | ||||
-rw-r--r-- | omx/audio/src/openmax_il/aac_dec/src/OMX_AacDec_Utils.c | 79 |
2 files changed, 96 insertions, 6 deletions
diff --git a/omx/audio/src/openmax_il/aac_dec/inc/OMX_AacDec_Utils.h b/omx/audio/src/openmax_il/aac_dec/inc/OMX_AacDec_Utils.h index 60ff9e6..f4eae9a 100644 --- a/omx/audio/src/openmax_il/aac_dec/inc/OMX_AacDec_Utils.h +++ b/omx/audio/src/openmax_il/aac_dec/inc/OMX_AacDec_Utils.h @@ -464,6 +464,14 @@ #define STEREO_INTERLEAVED_STREAM_AACDEC 2 #define STEREO_NONINTERLEAVED_STREAM_AACDEC 3 +/* ======================================================================= */ +/** + * pthread variable to indicate OMX returned all buffers to app + */ +/* ======================================================================= */ +pthread_mutex_t bufferReturned_mutex; +pthread_cond_t bufferReturned_condition; + /** * * AAC Decoder Profile:0 - MAIN, 1 - LC, 2 - SSR, 3 - LTP. @@ -921,6 +929,7 @@ typedef struct AACDEC_COMPONENT_PRIVATE #ifndef UNDER_CE pthread_mutex_t AlloBuf_mutex; pthread_cond_t AlloBuf_threshold; + OMX_U8 AlloBuf_waitingsignal; pthread_mutex_t InLoaded_mutex; @@ -1352,4 +1361,18 @@ OMX_U32 AACDEC_ParseHeader(OMX_BUFFERHEADERTYPE* pBufHeader, /* =========================================================================*/ OMX_U32 AACDEC_GetBits(OMX_U32* nPosition, OMX_U8 nBits, OMX_U8* pBuffer, OMX_BOOL bIcreasePosition); +/*=======================================================================*/ +/*! @fn SignalIfAllBuffersAreReturned + + * @brief Sends pthread signal to indicate OMX has returned all buffers to app + + * @param none + + * @Return void + + */ +/*=======================================================================*/ +void SignalIfAllBuffersAreReturned(AACDEC_COMPONENT_PRIVATE *pComponentPrivate); + + #endif diff --git a/omx/audio/src/openmax_il/aac_dec/src/OMX_AacDec_Utils.c b/omx/audio/src/openmax_il/aac_dec/src/OMX_AacDec_Utils.c index 3131633..ee3f3ba 100644 --- a/omx/audio/src/openmax_il/aac_dec/src/OMX_AacDec_Utils.c +++ b/omx/audio/src/openmax_il/aac_dec/src/OMX_AacDec_Utils.c @@ -1354,6 +1354,7 @@ OMX_U32 AACDEC_HandleCommand (AACDEC_COMPONENT_PRIVATE *pComponentPrivate) pComponentPrivate->pHandle->pApplicationPrivate, pComponentPrivate->pInputBufferList->pBufHdr[i]); pComponentPrivate->nEmptyBufferDoneCount++; + SignalIfAllBuffersAreReturned(pComponentPrivate); } } pComponentPrivate->pPortDef[INPUT_PORT_AACDEC]->bEnabled = OMX_FALSE; @@ -1704,7 +1705,9 @@ OMX_U32 AACDEC_HandleCommand (AACDEC_COMPONENT_PRIVATE *pComponentPrivate) pComponentPrivate->cbInfo.EmptyBufferDone (pComponentPrivate->pHandle, pComponentPrivate->pHandle->pApplicationPrivate, pComponentPrivate->pInputBufHdrPending[i]); + pComponentPrivate->nEmptyBufferDoneCount++; pComponentPrivate->pInputBufHdrPending[i] = NULL; + SignalIfAllBuffersAreReturned(pComponentPrivate); } pComponentPrivate->nNumInputBufPending=0; pComponentPrivate->cbInfo.EventHandler(pHandle, @@ -1757,8 +1760,10 @@ OMX_U32 AACDEC_HandleCommand (AACDEC_COMPONENT_PRIVATE *pComponentPrivate) pComponentPrivate->pHandle->pApplicationPrivate, pComponentPrivate->pOutputBufHdrPending[i] ); + pComponentPrivate->nFillBufferDoneCount++; pComponentPrivate->nOutStandingFillDones--; pComponentPrivate->pOutputBufHdrPending[i] = NULL; + SignalIfAllBuffersAreReturned(pComponentPrivate); } pComponentPrivate->nNumOutputBufPending=0; @@ -1865,8 +1870,7 @@ OMX_U32 AACDEC_ParseHeader(OMX_BUFFERHEADERTYPE* pBufHeader, pComponentPrivate->pHandle->pApplicationPrivate, pBufHeader); pComponentPrivate->nEmptyBufferDoneCount++; - - + SignalIfAllBuffersAreReturned(pComponentPrivate); return 0; } @@ -1919,12 +1923,16 @@ OMX_ERRORTYPE AACDEC_HandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE* pBufHeader, pComponentPrivate->cbInfo.EmptyBufferDone (pComponentPrivate->pHandle, pComponentPrivate->pHandle->pApplicationPrivate, pBufHeader); + pComponentPrivate->nEmptyBufferDoneCount++; + SignalIfAllBuffersAreReturned(pComponentPrivate); OMX_PRBUFFER2(pComponentPrivate->dbg, ":: %d %s In idle state return input buffers\n", __LINE__, __FUNCTION__); } else if (eDir == OMX_DirOutput) { pComponentPrivate->cbInfo.FillBufferDone (pComponentPrivate->pHandle, pComponentPrivate->pHandle->pApplicationPrivate, pBufHeader); + pComponentPrivate->nFillBufferDoneCount++; + SignalIfAllBuffersAreReturned(pComponentPrivate); OMX_PRBUFFER2(pComponentPrivate->dbg, ":: %d %s In idle state return output buffers\n", __LINE__, __FUNCTION__); } goto EXIT; @@ -2213,7 +2221,7 @@ OMX_ERRORTYPE AACDEC_HandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE* pBufHeader, pBufHeader ); pComponentPrivate->nEmptyBufferDoneCount++; - + SignalIfAllBuffersAreReturned(pComponentPrivate); } pComponentPrivate->lcml_nCntIp++; pComponentPrivate->lcml_nIpBuf++; @@ -2237,6 +2245,7 @@ OMX_ERRORTYPE AACDEC_HandleDataBuf_FromApp(OMX_BUFFERHEADERTYPE* pBufHeader, pComponentPrivate->pInputBufferList->pBufHdr[0] ); pComponentPrivate->nEmptyBufferDoneCount++; + SignalIfAllBuffersAreReturned(pComponentPrivate); } if(pBufHeader->pMarkData){ OMX_PRDSP2(pComponentPrivate->dbg, "%d:Detected pBufHeader->pMarkData\n",__LINE__); @@ -2526,6 +2535,7 @@ OMX_ERRORTYPE AACDEC_LCML_Callback (TUsnCodecEvent event,void * args [10]) pComponentPrivate->pHandle->pApplicationPrivate, pLcmlHdr->pBufHdr); pComponentPrivate->nEmptyBufferDoneCount++; + SignalIfAllBuffersAreReturned(pComponentPrivate); pComponentPrivate->lcml_nIpBuf--; pComponentPrivate->app_nBuf++; @@ -2543,7 +2553,9 @@ OMX_ERRORTYPE AACDEC_LCML_Callback (TUsnCodecEvent event,void * args [10]) pComponentPrivate->pHandle->pApplicationPrivate, pComponentPrivate->pOutputBufferList->pBufHdr[pComponentPrivate->nInvalidFrameCount++] ); + pComponentPrivate->nFillBufferDoneCount++; pComponentPrivate->numPendingBuffers--; + SignalIfAllBuffersAreReturned(pComponentPrivate); } else{ pComponentPrivate->nOutStandingFillDones++; eError = AACDEC_GetCorresponding_LCMLHeader(pComponentPrivate, pBuffer, OMX_DirOutput, &pLcmlHdr); @@ -2633,6 +2645,7 @@ OMX_ERRORTYPE AACDEC_LCML_Callback (TUsnCodecEvent event,void * args [10]) pLcmlHdr->pBufHdr ); pComponentPrivate->nFillBufferDoneCount++; + SignalIfAllBuffersAreReturned(pComponentPrivate); } pComponentPrivate->nOutStandingFillDones--; @@ -2650,14 +2663,18 @@ OMX_ERRORTYPE AACDEC_LCML_Callback (TUsnCodecEvent event,void * args [10]) pComponentPrivate->pHandle->pApplicationPrivate, pComponentPrivate->pInputBufHdrPending[i]); pComponentPrivate->pInputBufHdrPending[i] = NULL; + pComponentPrivate->nEmptyBufferDoneCount++; + SignalIfAllBuffersAreReturned(pComponentPrivate); } pComponentPrivate->nNumInputBufPending = 0; for (i=0; i < pComponentPrivate->nNumOutputBufPending; i++) { pComponentPrivate->cbInfo.FillBufferDone (pComponentPrivate->pHandle, pComponentPrivate->pHandle->pApplicationPrivate, pComponentPrivate->pOutputBufHdrPending[i]); + pComponentPrivate->nFillBufferDoneCount++; pComponentPrivate->nOutStandingFillDones--; pComponentPrivate->pOutputBufHdrPending[i] = NULL; + SignalIfAllBuffersAreReturned(pComponentPrivate); } pComponentPrivate->nNumOutputBufPending=0; pthread_mutex_lock(&pComponentPrivate->codecStop_mutex); @@ -2674,6 +2691,23 @@ OMX_ERRORTYPE AACDEC_LCML_Callback (TUsnCodecEvent event,void * args [10]) #ifdef RESOURCE_MANAGER_ENABLED rm_error = RMProxy_NewSendCommand(pComponentPrivate->pHandle, RMProxy_StateSet, OMX_AAC_Decoder_COMPONENT, OMX_StateIdle, 3456, NULL); #endif + if((pComponentPrivate->nEmptyThisBufferCount != pComponentPrivate->nEmptyBufferDoneCount) || (pComponentPrivate->nFillThisBufferCount != pComponentPrivate->nFillBufferDoneCount)) { + if(pthread_mutex_lock(&bufferReturned_mutex) != 0) + { + OMXDBG_PRINT(stderr, PRINT, 1, 0, "bufferReturned_mutex mutex lock error"); + } + OMXDBG_PRINT(stderr, PRINT, 1, 0, "pthread_cond_waiting for OMX to return all input and outbut buffers"); + pthread_cond_wait(&bufferReturned_condition, &bufferReturned_mutex); + OMXDBG_PRINT(stderr, PRINT, 1, 0, "OMX has returned all input and output buffers"); + if(pthread_mutex_unlock(&bufferReturned_mutex) != 0) + { + OMXDBG_PRINT(stderr, PRINT, 1, 0, "bufferReturned_mutex mutex unlock error"); + } + } + else + { + OMXDBG_PRINT(stderr, PRINT, 1, 0, "OMX has returned all input and output buffers"); + } if (pComponentPrivate->bPreempted == 0) { pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle, pComponentPrivate->pHandle->pApplicationPrivate, @@ -2887,8 +2921,9 @@ OMX_ERRORTYPE AACDEC_LCML_Callback (TUsnCodecEvent event,void * args [10]) pComponentPrivate->pInputBufHdrPending[i]); pComponentPrivate->nEmptyBufferDoneCount++; - pComponentPrivate->pInputBufHdrPending[i] = NULL; - } + SignalIfAllBuffersAreReturned(pComponentPrivate); + pComponentPrivate->pInputBufHdrPending[i] = NULL; + } pComponentPrivate->nNumInputBufPending=0; pthread_mutex_lock(&pComponentPrivate->codecFlush_mutex); @@ -2926,8 +2961,9 @@ OMX_ERRORTYPE AACDEC_LCML_Callback (TUsnCodecEvent event,void * args [10]) pComponentPrivate->pOutputBufHdrPending[i] ); pComponentPrivate->nOutStandingFillDones--; - pComponentPrivate->nFillBufferDoneCount++; + pComponentPrivate->nFillBufferDoneCount++; pComponentPrivate->pOutputBufHdrPending[i] = NULL; + SignalIfAllBuffersAreReturned(pComponentPrivate); } pComponentPrivate->nNumOutputBufPending=0; @@ -3870,5 +3906,36 @@ void AACDEC_ResourceManagerCallback(RMPROXY_COMMANDDATATYPE cbData) NULL); } } +*/ + /* ========================================================================== */ +/** +* @SignalIfAllBuffersAreReturned() This function send signals if OMX returned all buffers to app +* +* @param AACDEC_COMPONENT_PRIVATE *pComponentPrivate +* +* @pre None +* +* @post None +* +* @return None */ +/* ========================================================================== */ +void SignalIfAllBuffersAreReturned(AACDEC_COMPONENT_PRIVATE *pComponentPrivate) +{ + if((pComponentPrivate->nEmptyThisBufferCount == pComponentPrivate->nEmptyBufferDoneCount) && (pComponentPrivate->nFillThisBufferCount == pComponentPrivate->nFillBufferDoneCount)) + { + if(pthread_mutex_lock(&bufferReturned_mutex) != 0) + { + OMXDBG_PRINT(stderr, PRINT, 1, 0, "bufferReturned_mutex mutex lock error"); + } + pthread_cond_broadcast(&bufferReturned_condition); + OMXDBG_PRINT(stderr, PRINT, 1, 0, "Sending pthread signal that OMX has returned all buffers to app"); + if(pthread_mutex_unlock(&bufferReturned_mutex) != 0) + { + OMXDBG_PRINT(stderr, PRINT, 1, 0, "bufferReturned_mutex mutex unlock error"); + } + return; + } +} + |