common/video: added INVAILD_STATE in exceptionFlag
authorTaehwan Kim <t_h.kim@samsung.com>
Mon, 4 Mar 2013 04:11:38 +0000 (04:11 +0000)
committerHuisung Kang <hs1218.kang@samsung.com>
Tue, 5 Mar 2013 00:24:33 +0000 (09:24 +0900)
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 <t_h.kim@samsung.com>
component/common/Exynos_OMX_Basecomponent.c
component/common/Exynos_OMX_Baseport.c
component/common/Exynos_OMX_Baseport.h
component/video/dec/Exynos_OMX_Vdec.c
component/video/dec/Exynos_OMX_VdecControl.c
component/video/enc/Exynos_OMX_VencControl.c

index 4e91847ab7d238c6c576ce38c5b133478bb8c633..91cbf3fa812654acaaffce9d319dbcba465b53e7 100644 (file)
@@ -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)) {
index 42b2d98fb654d1ae21133500dec6f334b2fd3804..87b918a2547f13191564fe236ba72fce2a2d5bea 100644 (file)
@@ -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;
index 08022796cca89cf0d7f5e0231376babb49860506..69724712d105d37aeed54830c2b7b82aea96d664 100644 (file)
@@ -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
index 1b3948872a2e98fb16426b5b5af15cca7c7e5a93..2d39d32773f08aac8aa1a5cfd40f05da017256a6 100644 (file)
@@ -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;
index e5539884b7e13b0a5e1919f642f3347eadb8c7e7..ae85de6d648923fe497d098992ccb07541089a1d 100644 (file)
@@ -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++) {
index db5d7fc62f080326bf747f94334b94fb61af46e4..869531fb6b1db579efaf9b907ac626135958bce8 100644 (file)
@@ -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++) {