Added error handling in the state change from "Load state" to "Idle state".
authorSeungBeom Kim <sbcrux.kim@samsung.com>
Fri, 5 Oct 2012 04:59:28 +0000 (21:59 -0700)
committerJames Dong <jdong@google.com>
Wed, 17 Oct 2012 23:31:58 +0000 (16:31 -0700)
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 <sbcrux.kim@samsung.com>
Signed-off-by: Yunji Kim <yunji.kim@samsung.com>
exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.c
exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Basecomponent.h
exynos_omx/openmax/exynos_omx/component/common/Exynos_OMX_Baseport.c

index e5694a44fb3e216c4c5b2badb727e5d8ee72e2fa..f9769eff0ccb39f9bcfeb9984f90c88780cfd907 100644 (file)
@@ -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);
index 1b2abde02cb0107c8f991d6dbcb67088995232df..9f9ed3d216df1af32475687c34708d841e8e51d5 100644 (file)
@@ -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;
index f4f0066c7ffdb8df2edeb5fbf051e8ec2e03af85..9c0c42d0e86543aebacf4dfec610edb6112b3cd1 100644 (file)
@@ -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];