From d9966f64b1a4f195c099ccff95672d8fc7b8fed6 Mon Sep 17 00:00:00 2001 From: SeungBeom Kim Date: Thu, 4 Oct 2012 21:59:28 -0700 Subject: [PATCH] Added error handling in the state change from "Load state" to "Idle state". This patch fixes the ANR at reset/release time, caused by some failures in initilizating video decoders Bug: 7282066 Change-Id: Ic8440ff597dc4a3a6fa568c141c28e00dda518d1 Signed-off-by: SeungBeom Kim Signed-off-by: Yunji Kim --- .../common/Exynos_OMX_Basecomponent.c | 13 ++++++++++++ .../common/Exynos_OMX_Basecomponent.h | 2 ++ .../component/common/Exynos_OMX_Baseport.c | 20 +++++++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.c b/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.c index e5694a4..f9769ef 100644 --- a/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.c +++ b/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.c @@ -343,6 +343,11 @@ OMX_ERRORTYPE Exynos_OMX_ComponentStateSet(OMX_COMPONENTTYPE *pOMXComponent, OMX } else { if (CHECK_PORT_ENABLED(pExynosPort)) { Exynos_OSAL_SemaphoreWait(pExynosComponent->pExynosPort[i].loadedResource); + if (pExynosComponent->abendState == OMX_TRUE) { + Exynos_OSAL_SignalSet(pExynosComponent->abendStateEvent); + ret = Exynos_OMX_Release_Resource(pOMXComponent); + goto EXIT; + } pExynosPort->portDefinition.bPopulated = OMX_TRUE; } } @@ -1495,6 +1500,12 @@ OMX_ERRORTYPE Exynos_OMX_BaseComponent_Constructor( Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); goto EXIT; } + ret = Exynos_OSAL_SignalCreate(&pExynosComponent->abendStateEvent); + if (ret != OMX_ErrorNone) { + ret = OMX_ErrorInsufficientResources; + Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); + goto EXIT; + } pExynosComponent->bExitMessageHandlerThread = OMX_FALSE; Exynos_OSAL_QueueCreate(&pExynosComponent->messageQ, MAX_QUEUE_ELEMENTS); @@ -1555,6 +1566,8 @@ OMX_ERRORTYPE Exynos_OMX_BaseComponent_Destructor( Exynos_OSAL_ThreadTerminate(pExynosComponent->hMessageHandler); pExynosComponent->hMessageHandler = NULL; + Exynos_OSAL_SignalTerminate(pExynosComponent->abendStateEvent); + pExynosComponent->abendStateEvent = NULL; Exynos_OSAL_MutexTerminate(pExynosComponent->compMutex); pExynosComponent->compMutex = NULL; Exynos_OSAL_SemaphoreTerminate(pExynosComponent->msgSemaphoreHandle); diff --git a/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.h b/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.h index 1b2abde..9f9ed3d 100644 --- a/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.h +++ b/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.h @@ -58,6 +58,8 @@ typedef struct _EXYNOS_OMX_BASECOMPONENT OMX_STATETYPE currentState; EXYNOS_OMX_TRANS_STATETYPE transientState; + OMX_BOOL abendState; + OMX_HANDLETYPE abendStateEvent; EXYNOS_CODEC_TYPE codecType; EXYNOS_OMX_PRIORITYMGMTTYPE compPriority; diff --git a/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Baseport.c b/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Baseport.c index f4f0066..9c0c42d 100644 --- a/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Baseport.c +++ b/exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Baseport.c @@ -774,15 +774,16 @@ EXIT: OMX_ERRORTYPE Exynos_OMX_Port_Destructor(OMX_HANDLETYPE hComponent) { - OMX_ERRORTYPE ret = OMX_ErrorNone; - OMX_COMPONENTTYPE *pOMXComponent = NULL; + OMX_ERRORTYPE ret = OMX_ErrorNone; + OMX_COMPONENTTYPE *pOMXComponent = NULL; EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; EXYNOS_OMX_BASEPORT *pExynosPort = NULL; - FunctionIn(); - + OMX_S32 countValue = 0; int i = 0; + FunctionIn(); + if (hComponent == NULL) { ret = OMX_ErrorBadParameter; goto EXIT; @@ -797,6 +798,17 @@ OMX_ERRORTYPE Exynos_OMX_Port_Destructor(OMX_HANDLETYPE hComponent) goto EXIT; } pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; + + if (pExynosComponent->transientState == EXYNOS_OMX_TransStateLoadedToIdle) { + pExynosComponent->abendState = OMX_TRUE; + for (i = 0; i < ALL_PORT_NUM; i++) { + pExynosPort = &pExynosComponent->pExynosPort[i]; + Exynos_OSAL_SemaphorePost(pExynosPort->loadedResource); + } + Exynos_OSAL_SignalWait(pExynosComponent->abendStateEvent, DEF_MAX_WAIT_TIME); + Exynos_OSAL_SignalReset(pExynosComponent->abendStateEvent); + } + for (i = 0; i < ALL_PORT_NUM; i++) { pExynosPort = &pExynosComponent->pExynosPort[i]; -- 2.20.1