From 4650bb727d7c5a903d974789325dff1f8376e95c Mon Sep 17 00:00:00 2001 From: Taehwan Kim Date: Mon, 4 Mar 2013 04:11:38 +0000 Subject: [PATCH] common/video: added INVAILD_STATE in exceptionFlag Waits for loadedResource semaphore during OMX_CommandPortEnable command. If occur an error from OpenMAX IL Client before completing resource allocation, loadedResource semaphore couldn't be released. added INVAILD_STATE in exceptionFlag in order to release loadedResource semaphore in above case. Change-Id: I31e1c398136d2fcbcf886408683c1d21625e1794 Signed-off-by: Taehwan Kim --- component/common/Exynos_OMX_Basecomponent.c | 16 ++++++++++++++++ component/common/Exynos_OMX_Baseport.c | 5 +++++ component/common/Exynos_OMX_Baseport.h | 1 + component/video/dec/Exynos_OMX_Vdec.c | 3 ++- component/video/dec/Exynos_OMX_VdecControl.c | 6 +++++- component/video/enc/Exynos_OMX_VencControl.c | 7 +++++-- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/component/common/Exynos_OMX_Basecomponent.c b/component/common/Exynos_OMX_Basecomponent.c index 4e91847..91cbf3f 100644 --- a/component/common/Exynos_OMX_Basecomponent.c +++ b/component/common/Exynos_OMX_Basecomponent.c @@ -664,6 +664,22 @@ static OMX_ERRORTYPE Exynos_StateSet(EXYNOS_OMX_BASECOMPONENT *pExynosComponent, } Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "to OMX_StateLoaded"); } else if ((destState == OMX_StateIdle) && (pExynosComponent->currentState == OMX_StateExecuting)) { + EXYNOS_OMX_BASEPORT *pExynosPort = NULL; + + pExynosPort = &(pExynosComponent->pExynosPort[INPUT_PORT_INDEX]); + if ((pExynosPort->portDefinition.bEnabled == OMX_FALSE) && + (pExynosPort->portState == OMX_StateIdle)) { + pExynosPort->exceptionFlag = INVALID_STATE; + Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource); + } + + pExynosPort = &(pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]); + if ((pExynosPort->portDefinition.bEnabled == OMX_FALSE) && + (pExynosPort->portState == OMX_StateIdle)) { + pExynosPort->exceptionFlag = INVALID_STATE; + Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource); + } + pExynosComponent->transientState = EXYNOS_OMX_TransStateExecutingToIdle; Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "to OMX_StateIdle"); } else if ((destState == OMX_StateExecuting) && (pExynosComponent->currentState == OMX_StateIdle)) { diff --git a/component/common/Exynos_OMX_Baseport.c b/component/common/Exynos_OMX_Baseport.c index 42b2d98..87b918a 100644 --- a/component/common/Exynos_OMX_Baseport.c +++ b/component/common/Exynos_OMX_Baseport.c @@ -156,6 +156,11 @@ OMX_ERRORTYPE Exynos_OMX_EnablePort(OMX_COMPONENTTYPE *pOMXComponent, OMX_S32 po if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) { Exynos_OSAL_SemaphoreWait(pExynosPort->loadedResource); + + if (pExynosPort->exceptionFlag == INVALID_STATE) { + pExynosPort->exceptionFlag = NEED_PORT_DISABLE; + goto EXIT; + } pExynosPort->portDefinition.bPopulated = OMX_TRUE; } pExynosPort->exceptionFlag = GENERAL_STATE; diff --git a/component/common/Exynos_OMX_Baseport.h b/component/common/Exynos_OMX_Baseport.h index 0802279..6972471 100644 --- a/component/common/Exynos_OMX_Baseport.h +++ b/component/common/Exynos_OMX_Baseport.h @@ -127,6 +127,7 @@ typedef enum _EXYNOS_OMX_EXCEPTION_STATE GENERAL_STATE = 0x00, NEED_PORT_FLUSH, NEED_PORT_DISABLE, + INVALID_STATE, } EXYNOS_OMX_EXCEPTION_STATE; typedef enum _EXYNOS_OMX_PLANE diff --git a/component/video/dec/Exynos_OMX_Vdec.c b/component/video/dec/Exynos_OMX_Vdec.c index 1b39488..2d39d32 100644 --- a/component/video/dec/Exynos_OMX_Vdec.c +++ b/component/video/dec/Exynos_OMX_Vdec.c @@ -713,7 +713,8 @@ OMX_ERRORTYPE Exynos_OMX_SrcInputBufferProcess(OMX_HANDLETYPE hComponent) Exynos_OSAL_SleepMillisec(0); if ((CHECK_PORT_BEING_FLUSHED(exynosInputPort)) || - ((exynosOutputPort->exceptionFlag == NEED_PORT_DISABLE) && (ret == OMX_ErrorInputDataDecodeYet))) + ((exynosOutputPort->exceptionFlag == NEED_PORT_DISABLE) && (ret == OMX_ErrorInputDataDecodeYet)) || + (exynosOutputPort->exceptionFlag == INVALID_STATE)) break; if (exynosInputPort->portState != OMX_StateIdle) break; diff --git a/component/video/dec/Exynos_OMX_VdecControl.c b/component/video/dec/Exynos_OMX_VdecControl.c index e553988..ae85de6 100644 --- a/component/video/dec/Exynos_OMX_VdecControl.c +++ b/component/video/dec/Exynos_OMX_VdecControl.c @@ -298,12 +298,16 @@ OMX_ERRORTYPE Exynos_OMX_FreeBuffer( goto EXIT; } - if ((pExynosPort->portState != OMX_StateLoaded) && (pExynosPort->portState != OMX_StateInvalid)) { + if (((pExynosPort->portState != OMX_StateLoaded) && + (pExynosPort->portState != OMX_StateInvalid)) && + (pExynosPort->portDefinition.bEnabled != OMX_FALSE)) { (*(pExynosComponent->pCallbacks->EventHandler)) (pOMXComponent, pExynosComponent->callbackData, (OMX_U32)OMX_EventError, (OMX_U32)OMX_ErrorPortUnpopulated, nPortIndex, NULL); + ret = OMX_ErrorInvalidState; + goto EXIT; } for (i = 0; i < /*pExynosPort->portDefinition.nBufferCountActual*/MAX_BUFFER_NUM; i++) { diff --git a/component/video/enc/Exynos_OMX_VencControl.c b/component/video/enc/Exynos_OMX_VencControl.c index db5d7fc..869531f 100644 --- a/component/video/enc/Exynos_OMX_VencControl.c +++ b/component/video/enc/Exynos_OMX_VencControl.c @@ -314,13 +314,16 @@ OMX_ERRORTYPE Exynos_OMX_FreeBuffer( goto EXIT; } - if ((pExynosPort->portState != OMX_StateLoaded) && - (pExynosPort->portState != OMX_StateInvalid)) { + if (((pExynosPort->portState != OMX_StateLoaded) && + (pExynosPort->portState != OMX_StateInvalid)) && + (pExynosPort->portDefinition.bEnabled != OMX_FALSE)) { (*(pExynosComponent->pCallbacks->EventHandler)) (pOMXComponent, pExynosComponent->callbackData, (OMX_U32)OMX_EventError, (OMX_U32)OMX_ErrorPortUnpopulated, nPortIndex, NULL); + ret = OMX_ErrorInvalidState; + goto EXIT; } for (i = 0; i < /*pExynosPort->portDefinition.nBufferCountActual*/MAX_BUFFER_NUM; i++) { -- 2.20.1