summaryrefslogtreecommitdiff
path: root/omx
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2009-11-30 10:22:53 -0800
committerJames Dong <jdong@google.com>2009-12-03 10:39:11 -0800
commit3000a016292019e74a9afbd65aa95c669c1c4b94 (patch)
tree7930b2af717ac91f9b305f8186fba76a2e754e4d /omx
parent75654962d82cc9054c198ce88fc2db0c56b16232 (diff)
downloadomap3-3000a016292019e74a9afbd65aa95c669c1c4b94.tar.gz
Fix race conditions where modification of some shared counters between threads was not atomic.
Also, Log error condition from LCML_Callback.
Diffstat (limited to 'omx')
-rw-r--r--omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h8
-rw-r--r--omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Thread.c17
-rw-r--r--omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c29
-rw-r--r--omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c6
4 files changed, 33 insertions, 27 deletions
diff --git a/omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h b/omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h
index 0f17067..6741d8f 100644
--- a/omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h
+++ b/omx/video/src/openmax_il/video_decode/inc/OMX_VideoDec_Utils.h
@@ -941,10 +941,10 @@ typedef struct VIDDEC_COMPONENT_PRIVATE
#endif
VIDDEC_RMPROXY_STATES eRMProxyState;
- OMX_U8 nInputBCountDsp;
- OMX_U8 nOutputBCountDsp;
- OMX_U8 nInputBCountApp;
- OMX_U8 nOutputBCountApp;
+ volatile int32_t nInputBCountDsp;
+ volatile int32_t nOutputBCountDsp;
+ volatile int32_t nInputBCountApp;
+ volatile int32_t nOutputBCountApp;
VIDDEC_CBUFFER_BUFFERFLAGS aBufferFlags[CBUFFER_SIZE];
VIDDEC_LCML_STATES eLCMLState;
diff --git a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Thread.c b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Thread.c
index 7cfcf4b..92c7cd4 100644
--- a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Thread.c
+++ b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Thread.c
@@ -72,6 +72,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
+#include <cutils/atomic.h>
#include "OMX_VideoDecoder.h"
#include "OMX_VideoDec_Utils.h"
@@ -291,7 +292,7 @@ void* OMX_VidDec_Thread (void* pThreadData)
OMX_TI_ErrorSevere,
"Error from Component Thread while processing dsp Responses");
}
- pComponentPrivate->nOutputBCountDsp--;
+ android_atomic_dec(&pComponentPrivate->nOutputBCountDsp);
}
if ((FD_ISSET(pComponentPrivate->filled_inpBuf_Q[VIDDEC_PIPE_READ], &rfds))){
OMX_PRSTATE2(pComponentPrivate->dbg, "eExecuteToIdle 0x%x\n",pComponentPrivate->eExecuteToIdle);
@@ -312,7 +313,7 @@ void* OMX_VidDec_Thread (void* pThreadData)
OMX_TI_ErrorSevere,
"Error from Component Thread while processing input buffer");
}
- pComponentPrivate->nInputBCountApp--;
+ android_atomic_dec(&pComponentPrivate->nInputBCountApp);
}
}
if (FD_ISSET(pComponentPrivate->free_inpBuf_Q[VIDDEC_PIPE_READ], &rfds)) {
@@ -330,7 +331,7 @@ void* OMX_VidDec_Thread (void* pThreadData)
OMX_TI_ErrorSevere,
"Error from Component Thread while processing free input buffer");
}
- pComponentPrivate->nInputBCountDsp--;
+ android_atomic_dec(&pComponentPrivate->nInputBCountDsp);
}
if (FD_ISSET(pComponentPrivate->free_outBuf_Q[VIDDEC_PIPE_READ], &rfds)) {
if(pComponentPrivate->bDynamicConfigurationInProgress){
@@ -348,7 +349,7 @@ void* OMX_VidDec_Thread (void* pThreadData)
OMX_TI_ErrorSevere,
"Error from Component Thread while processing free output buffer");
}
- pComponentPrivate->nOutputBCountApp--;
+ android_atomic_dec(&pComponentPrivate->nOutputBCountApp);
}
}
}
@@ -450,7 +451,7 @@ void* OMX_VidDec_Return (void* pThreadData)
OMX_TI_ErrorSevere,
"Error from Component Thread while processing dsp Responses");
}
- pComponentPrivate->nOutputBCountDsp--;
+ android_atomic_dec(&pComponentPrivate->nOutputBCountDsp);
}
if ((FD_ISSET(pComponentPrivate->filled_inpBuf_Q[VIDDEC_PIPE_READ], &rfds))){
OMX_PRSTATE2(pComponentPrivate->dbg, "eExecuteToIdle 0x%x\n",pComponentPrivate->eExecuteToIdle);
@@ -465,7 +466,7 @@ void* OMX_VidDec_Return (void* pThreadData)
OMX_TI_ErrorSevere,
"Error from Component Thread while processing input buffer");
}
- pComponentPrivate->nInputBCountApp--;
+ android_atomic_dec(&pComponentPrivate->nInputBCountApp);
}
}
if (FD_ISSET(pComponentPrivate->free_inpBuf_Q[VIDDEC_PIPE_READ], &rfds)) {
@@ -479,7 +480,7 @@ void* OMX_VidDec_Return (void* pThreadData)
OMX_TI_ErrorSevere,
"Error from Component Thread while processing free input buffer");
}
- pComponentPrivate->nInputBCountDsp--;
+ android_atomic_dec(&pComponentPrivate->nInputBCountDsp);
}
if (FD_ISSET(pComponentPrivate->free_outBuf_Q[VIDDEC_PIPE_READ], &rfds)) {
OMX_PRSTATE2(pComponentPrivate->dbg, "eExecuteToIdle 0x%x\n",pComponentPrivate->eExecuteToIdle);
@@ -493,7 +494,7 @@ void* OMX_VidDec_Return (void* pThreadData)
OMX_TI_ErrorSevere,
"Error from Component Thread while processing free output buffer");
}
- pComponentPrivate->nOutputBCountApp--;
+ android_atomic_dec(&pComponentPrivate->nOutputBCountApp);
}
}
}
diff --git a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c
index 72740a6..5e339e0 100644
--- a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c
+++ b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDec_Utils.c
@@ -2224,7 +2224,6 @@ OMX_ERRORTYPE VIDDEC_HandleCommandFlush(VIDDEC_COMPONENT_PRIVATE *pComponentPriv
OMX_VidDec_Return(pComponentPrivate);
VIDDEC_ReturnBuffers(pComponentPrivate, VIDDEC_INPUT_PORT, OMX_TRUE);
if(bPass) {
- // LOGI("VIDDEC_HandleCommandFlush: Input port flush completes");
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
OMX_EventCmdComplete,
@@ -2261,7 +2260,6 @@ OMX_ERRORTYPE VIDDEC_HandleCommandFlush(VIDDEC_COMPONENT_PRIVATE *pComponentPriv
OMX_VidDec_Return(pComponentPrivate);
VIDDEC_ReturnBuffers(pComponentPrivate, VIDDEC_OUTPUT_PORT, OMX_TRUE);
if(bPass) {
- // LOGI("VIDDEC_HandleCommandFlush: Output port flush completes");
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
OMX_EventCmdComplete,
@@ -7808,27 +7806,27 @@ OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10])
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
pComponentPrivate->bTransPause = 1;
}
- if (event == EMMCodecAlgCtrlAck) {
+ else if (event == EMMCodecAlgCtrlAck) {
VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
pComponentPrivate->bTransPause = 1;
}
- if (event == EMMCodecProcessingStoped) {
+ else if (event == EMMCodecProcessingStoped) {
VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
pComponentPrivate->bTransPause = 1;
pComponentPrivate->bIsPaused = 0;
}
- if (event == EMMCodecProcessingStarted) {
+ else if (event == EMMCodecProcessingStarted) {
VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
pComponentPrivate->bTransPause = 1;
pComponentPrivate->bIsPaused = 0;
}
- if (event == EMMCodecBufferProcessed) {
+ else if (event == EMMCodecBufferProcessed) {
OMX_PRDSP2(pComponentPrivate->dbg, "EMMCodecBufferProcessed 0x%lx\n", (OMX_U32)argsCb [0]);
if ((OMX_U32)argsCb [0] == EMMCodecOuputBuffer) {
OMX_PRBUFFER1(pComponentPrivate->dbg, "EMMCodecOuputBuffer\n");
@@ -7889,7 +7887,7 @@ OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10])
/*}*/
OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nFilledLen %lu\n", pBuffHead->nFilledLen);
pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pOutputPortPrivate;
- pComponentPrivate->nOutputBCountDsp++;
+ android_atomic_inc(&pComponentPrivate->nOutputBCountDsp);
pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT;
OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner);
#ifdef __PERF_INSTRUMENTATION__
@@ -7982,7 +7980,7 @@ OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10])
}
}
/************************************************************************************************/
- if (event == EMMCodecBufferNotProcessed) {
+ else if (event == EMMCodecBufferNotProcessed) {
OMX_PRDSP2(pComponentPrivate->dbg, "EMMCodecBufferNotProcessed\n");
if ((OMX_U32)argsCb [0] == EMMCodecOuputBuffer) {
OMX_BUFFERHEADERTYPE* pBuffHead = NULL;
@@ -8041,7 +8039,7 @@ OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10])
/*}*/
OMX_PRBUFFER1(pComponentPrivate->dbg, "pBuffHead->nFilledLen %lu\n", pBuffHead->nFilledLen);
pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pOutputPortPrivate;
- pComponentPrivate->nOutputBCountDsp++;
+ android_atomic_inc(&pComponentPrivate->nOutputBCountDsp);
pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT;
OMX_PRBUFFER1(pComponentPrivate->dbg, "eBufferOwner 0x%x\n", pBufferPrivate->eBufferOwner);
#ifdef __PERF_INSTRUMENTATION__
@@ -8133,7 +8131,7 @@ OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10])
}
}
/************************************************************************************************/
- if (event == EMMCodecDspError) {
+ else if (event == EMMCodecDspError) {
OMX_PRDSP2(pComponentPrivate->dbg, "EMMCodecDspError\n");
if((argsCb[4] == (void *)NULL) && (argsCb[5] == (void*)NULL)) {
OMX_PRDSP4(pComponentPrivate->dbg, "DSP MMU_Fault\n");
@@ -8159,6 +8157,7 @@ OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10])
OMX_PRDSP2(pComponentPrivate->dbg, "Received PLAYCOMPLETED\n");
}
else {
+ OMX_PRDSP4(pComponentPrivate->dbg, "Error from the DSP: argsCb[5]=%d.\n", (int)argsCb [5]);
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
OMX_EventError,
@@ -8168,6 +8167,7 @@ OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10])
}
}
else {
+ OMX_PRDSP4(pComponentPrivate->dbg, "Error from the DSP: argsCb[4]=%d.\n", (int)argsCb [4]);
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
OMX_EventError,
@@ -8178,12 +8178,13 @@ OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10])
}
}
else {
+ OMX_PRDSP4(pComponentPrivate->dbg, "LCML Halted: argsCb[0]=%d.\n", (int)argsCb [0]);
pComponentPrivate->bLCMLHalted = OMX_TRUE;
pComponentPrivate->pHandle->SendCommand( pComponentPrivate->pHandle, OMX_CommandStateSet, -2, 0);
}
}
- if (event == EMMCodecInternalError || event == EMMCodecInitError) {
+ else if (event == EMMCodecInternalError || event == EMMCodecInitError) {
OMX_PRDSP4(pComponentPrivate->dbg, "EMMCodecInternalError || EMMCodecInitError\n");
pComponentPrivate->cbInfo.EventHandler(pComponentPrivate->pHandle,
pComponentPrivate->pHandle->pApplicationPrivate,
@@ -8192,13 +8193,17 @@ OMX_ERRORTYPE VIDDEC_LCML_Callback (TUsnCodecEvent event,void * argsCb [10])
OMX_TI_ErrorCritical,
"Error from the DSP");
}
- if (event == EMMCodecStrmCtrlAck) {
+ else if (event == EMMCodecStrmCtrlAck) {
if ((int)argsCb [0] == USN_ERR_NONE) {
OMX_PRDSP2(pComponentPrivate->dbg, "EMMCodecStrmCtrlAck\n");
VIDDEC_PTHREAD_MUTEX_LOCK(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_SIGNAL(pComponentPrivate->sMutex);
VIDDEC_PTHREAD_MUTEX_UNLOCK(pComponentPrivate->sMutex);
+ } else {
+ OMX_PRDSP4(pComponentPrivate->dbg, "EMMCodecStrmCtrlAck: argsCb[0]=%d\n", (int)argsCb [0]);
}
+ } else {
+ OMX_PRDSP4(pComponentPrivate->dbg, "Unknown event: %d\n", event);
}
EXIT:
diff --git a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c
index 71b16f6..5e4fda9 100644
--- a/omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c
+++ b/omx/video/src/openmax_il/video_decode/src/OMX_VideoDecoder.c
@@ -2309,7 +2309,7 @@ static OMX_ERRORTYPE VIDDEC_EmptyThisBuffer (OMX_HANDLETYPE pComponent,
pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pInputPortPrivate;
ret = pBufferPrivate->eBufferOwner;
pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT;
- pComponentPrivate->nInputBCountApp++;
+ android_atomic_inc(&pComponentPrivate->nInputBCountApp);
OMX_PRBUFFER1(pComponentPrivate->dbg, "Writing pBuffer 0x%p OldeBufferOwner %ld nAllocLen %lu nFilledLen %lu eBufferOwner %d\n",
pBuffHead, ret,pBuffHead->nAllocLen,pBuffHead->nFilledLen,pBufferPrivate->eBufferOwner);
@@ -2391,9 +2391,9 @@ static OMX_ERRORTYPE VIDDEC_FillThisBuffer (OMX_HANDLETYPE pComponent,
pBufferPrivate = (VIDDEC_BUFFER_PRIVATE* )pBuffHead->pOutputPortPrivate;
ret = pBufferPrivate->eBufferOwner;
pBufferPrivate->eBufferOwner = VIDDEC_BUFFER_WITH_COMPONENT;
- pComponentPrivate->nOutputBCountApp++;
+ android_atomic_inc(&pComponentPrivate->nOutputBCountApp);
pBuffHead->nFilledLen = 0;
- /*pBuffHead->nFlags = 0;*/
+ pBuffHead->nFlags = 0; // Clear flags
OMX_PRBUFFER1(pComponentPrivate->dbg, "Writing pBuffer 0x%p OldeBufferOwner %d eBufferOwner %d nFilledLen %lu\n",
pBuffHead, ret,pBufferPrivate->eBufferOwner,pBuffHead->nFilledLen);
ret = write (pComponentPrivate->free_outBuf_Q[1], &(pBuffHead), sizeof (pBuffHead));