OMX_ERRORTYPE OMX_CONF_WaitForResourcesTest(OMX_IN OMX_STRING cComponentName)
    {
        /* Interop test 4.7: Wait For Resources */
        /* ---------------------------------------
         * 1. Load component
         * 2. Transition to idle
         * 3. Repeat from steps 1-3 until transition to idle returns
         *    OMX_ErrorInsufficientResources and transitions to Wait state
         * 4. Switch one of the previous components to the loaded state to free resources
         * 5. Verify the component in the WaitForResources state transitions to idle
         */

        OMX_HANDLETYPE hComp[1000];
        OMX_U32 i, nComp = 0;
        OMX_ERRORTYPE  eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE  oCallbacks;
        OMXWFRTESTDATA    oAppData[1000];
        OMX_STATETYPE     eState = OMX_StateLoaded;
        OMX_BOOL          bTimeout  = OMX_FALSE;
        OMX_PRIORITYMGMTTYPE oPriority;
        OMX_HANDLETYPE hTraceComp[1000];
        OMX_HANDLETYPE hEventStateChange;
        OMX_ERRORTYPE eErrorCleanup;
        OMX_PTR pWrappedAppData[1000];
        OMX_CALLBACKTYPE *pWrappedCallbacks[1000];
        char szInstantiationName[256];

        /* Initialize data */
        oCallbacks.EventHandler         = WaitResEventHandler;
        oCallbacks.EmptyBufferDone      = StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone       = StubbedFillBufferDone;

        /* Begin test */
        eError = OMX_Init();
        if (OMX_ErrorNone != eError) return OMX_ErrorUndefined;

        hEventStateChange       = 0;
        hEventStateChangeIdle   = 0;
        hEventStateChangeLoaded = 0;
        eError = OMX_OSAL_EventCreate(&hEventStateChange);
        OMX_CONF_FAIL_IF_ERROR(eError);
        eError = OMX_OSAL_EventCreate(&hEventStateChangeIdle);
        OMX_CONF_FAIL_IF_ERROR(eError);
        eError = OMX_OSAL_EventCreate(&hEventStateChangeLoaded);
        OMX_CONF_FAIL_IF_ERROR(eError);

        INIT_PARAM(oPriority);
        oPriority.nGroupPriority = OMX_RESOURCETEST_PRIORITY_LOW;
        oPriority.nGroupID       = 1;


        nComp = 0;
        do
        {
            hComp[nComp] = hTraceComp[nComp] = NULL;
            GetInstantiationName(cComponentName, nComp, szInstantiationName);
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Trying to create and idle instantiation %i (priority = %i)\n",
                           nComp, OMX_RESOURCETEST_PRIORITY_LOW);
            if (nComp >= 1000)
            {
                OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Test unable to complete. Too many components requested (%d)\n", nComp);
                eError = OMX_ErrorUndefined;
                goto OMX_CONF_TEST_FAIL;
            }

            oAppData[nComp].bErrorInsufficientResources = OMX_FALSE;
            oAppData[nComp].hEventStateChange      = hEventStateChange;
            oAppData[nComp].nInstantiation = nComp;

            eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR) & oAppData[nComp], szInstantiationName,
                                                   &pWrappedCallbacks[nComp], &pWrappedAppData[nComp]);
            OMX_CONF_FAIL_IF_ERROR(eError);

            hComp[nComp] = NULL;
            eError = OMX_GetHandle(&hComp[nComp], cComponentName, pWrappedAppData[nComp], pWrappedCallbacks[nComp]);
            OMX_CONF_FAIL_IF_ERROR(eError); /* Problem acquiring handle. bail. */

            eError = OMX_CONF_ComponentTracerCreate(hComp[nComp], szInstantiationName, &hTraceComp[nComp]);
            OMX_CONF_FAIL_IF_ERROR(eError);

            /* Set priority and transition to idle */
            eError = OMX_SetParameter(hTraceComp[nComp], OMX_IndexParamPriorityMgmt, &oPriority);
            OMX_CONF_FAIL_IF_ERROR(eError);

            /* Disable all ports so we can go idle without buffers */
            eError = DisableAllPorts(hTraceComp[nComp]);
            OMX_CONF_FAIL_IF_ERROR(eError);

            eError = OMX_SendCommand(hTraceComp[nComp], OMX_CommandStateSet, OMX_StateIdle, 0);
            OMX_CONF_FAIL_IF_ERROR(eError);
            OMX_OSAL_EventWait(hEventStateChange, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
            if (bTimeout == OMX_TRUE)
            {
                eError = OMX_ErrorTimeout;
                goto OMX_CONF_TEST_FAIL;
            }
            OMX_OSAL_EventReset(hEventStateChange);

            eError = OMX_GetState(hTraceComp[nComp], &eState);
            OMX_CONF_FAIL_IF_ERROR(eError);
            nComp++;

        }
        while (!oAppData[nComp-1].bErrorInsufficientResources);

        nComp--;

        /* check that the last try stayed in loaded because of insufficient resources */
        if ((eState != OMX_StateLoaded) || !oAppData[nComp].bErrorInsufficientResources)
        {
            eError = OMX_ErrorUndefined;
            goto OMX_CONF_TEST_FAIL;
        }

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Instantiation %i failed to idle (insuffient resources)\n", nComp);

        /* tell last try it to wait for resources */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Telling instantiation %i to wait for resources\n", nComp);
        OMX_OSAL_EventReset(hEventStateChange);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hTraceComp[nComp], OMX_CommandStateSet, OMX_StateWaitForResources, 0));
        OMX_OSAL_EventWait(hEventStateChange, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (bTimeout == OMX_TRUE)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: Timed out waiting for state change from instantiation %i\n", nComp);
            eError = OMX_ErrorTimeout;
            goto OMX_CONF_TEST_FAIL;
        }
        OMX_CONF_FAIL_IF_ERROR(OMX_GetState(hTraceComp[nComp], &eState));
        if (eState != OMX_StateWaitForResources)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: State of instantiation %i is not OMX_StateWaitForResources\n", nComp);
            eError = OMX_ErrorUndefined;
            goto OMX_CONF_TEST_FAIL;
        }

        /* transition first try to loaded */
        OMX_OSAL_EventReset(hEventStateChange);
        OMX_OSAL_EventReset(hEventStateChangeIdle);
        OMX_OSAL_EventReset(hEventStateChangeLoaded);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Telling instantiation 0 to go to loaded\n", nComp);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hTraceComp[0], OMX_CommandStateSet, OMX_StateLoaded, 0));
        OMX_OSAL_EventWait(hEventStateChangeLoaded, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (bTimeout == OMX_TRUE)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: Timed out waiting for state change from instantiation 0\n");
            eError = OMX_ErrorTimeout;
            goto OMX_CONF_TEST_FAIL;
        }
        OMX_CONF_FAIL_IF_ERROR(OMX_GetState(hTraceComp[0], &eState));
        if (eState != OMX_StateLoaded)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: State of instantiation 0 is not OMX_StateLoaded\n");
            eError = OMX_ErrorUndefined;
            goto OMX_CONF_TEST_FAIL;
        }

        /* wait for last try to get resources */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Waiting for instantiation %i to go to idle\n", nComp);
        OMX_OSAL_EventWait(hEventStateChangeIdle, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
        if (bTimeout == OMX_TRUE)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: Timed out waiting for state change from instantiation %i\n", nComp);
            eError = OMX_ErrorTimeout;
            goto OMX_CONF_TEST_FAIL;
        }
        OMX_CONF_FAIL_IF_ERROR(OMX_GetState(hTraceComp[nComp], &eState));
        if (eState != OMX_StateIdle)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO,
                           "-ERROR: State of instantiation %i is not OMX_StateIdle\n", nComp);
            eError = OMX_ErrorUndefined;
            goto OMX_CONF_TEST_FAIL;
        }

OMX_CONF_TEST_FAIL:
        /* Cleanup */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Cleaning up\n");
        for (i = 1;i <= nComp;i++)
        {
            OMX_ERRORTYPE eErrorCleanup;

            if (hTraceComp[i] != NULL)
            {
                OMX_OSAL_EventReset(hEventStateChange);
                eErrorCleanup = OMX_SendCommand(hTraceComp[i], OMX_CommandStateSet, OMX_StateLoaded, 0);
                if (OMX_ErrorNone == eErrorCleanup)
                {
                    OMX_OSAL_EventWait(hEventStateChange, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimeout);
                }
            }
        }

        for (i = 0;i <= nComp;i++)
        {
            OMX_OSAL_EventReset(hEventStateChange);
            OMX_OSAL_EventWait(hEventStateChange, 20, &bTimeout);
            if (hComp[i] != NULL)
                eErrorCleanup = OMX_FreeHandle(hComp[i]);
        }

        for (i = 0;i <= nComp;i++)
        {
            /* unset trace component */
            if (hTraceComp[i] != NULL)
                OMX_CONF_ComponentTracerDestroy(hTraceComp[i]);
        }

        for (i = 0;i <= nComp;i++)
        {
            OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks[i], pWrappedAppData[i]);
        }

        if (hEventStateChange)
        {
            OMX_OSAL_EventDestroy(hEventStateChange);
        }

        if (hEventStateChangeIdle)
        {
            OMX_OSAL_EventDestroy(hEventStateChangeIdle);
        }

        if (hEventStateChangeLoaded)
        {
            OMX_OSAL_EventDestroy(hEventStateChangeLoaded);
        }

        OMX_Deinit();

        return eError;
    }
    OMX_ERRORTYPE OMX_CONF_ResourceExhaustionTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_ERRORTYPE eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE oCallbacks;
        ResourceExhaustionTestContext oAppData;
        OMX_CALLBACKTYPE *pWrapCallbacks;
        OMX_PTR pWrapAppData;
        ResourceExhaustionTestContext *pCtxt;
        OMX_U32 i;

        pCtxt = &oAppData;
        memset(pCtxt, 0x0, sizeof(ResourceExhaustionTestContext));

        oCallbacks.EventHandler    =  ResourceExhaustionTest_EventHandler;
        oCallbacks.EmptyBufferDone =  StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone  =  StubbedFillBufferDone;

        eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR)pCtxt, cComponentName,
                                               &pWrapCallbacks, &pWrapAppData);

        OMX_OSAL_EventCreate(&pCtxt->hStateSetEvent);
        OMX_OSAL_EventReset(pCtxt->hStateSetEvent);

        /* Initialize OpenMax */
        eError = OMX_Init();
        OMX_CONF_BAIL_IF_ERROR(eError);

        eError = ResourceExhaustionTest_LOAD(pCtxt, cComponentName, pWrapAppData, pWrapCallbacks);
        OMX_CONF_BAIL_IF_ERROR(eError);

        /* detect all audio ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[0], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp[pCtxt->nInst], OMX_IndexParamAudioInit,
                                  (OMX_PTR) & pCtxt->sPortParam[0]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i audio ports starting at %i \n",
                       pCtxt->sPortParam[0].nPorts, pCtxt->sPortParam[0].nStartPortNumber);

        /* detect all video ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[1], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp[pCtxt->nInst], OMX_IndexParamVideoInit,
                                  (OMX_PTR) & pCtxt->sPortParam[1]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i video ports starting at %i \n",
                       pCtxt->sPortParam[1].nPorts, pCtxt->sPortParam[1].nStartPortNumber);

        /* detect all image ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[2], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp[pCtxt->nInst], OMX_IndexParamImageInit,
                                  (OMX_PTR) & pCtxt->sPortParam[2]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i image ports starting at %i \n",
                       pCtxt->sPortParam[2].nPorts, pCtxt->sPortParam[2].nStartPortNumber);

        /* detect all other ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[3], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp[pCtxt->nInst], OMX_IndexParamOtherInit,
                                  (OMX_PTR) & pCtxt->sPortParam[3]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i other ports starting at %i \n",
                       pCtxt->sPortParam[3].nPorts, pCtxt->sPortParam[3].nStartPortNumber);

        OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateIdle));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Repeatedly load and idle component\n");
        /* JVW-NVIDIA: set bound to MAX_INSTANCE-1 http://cvs.khronos.org/bugzilla/show_bug.cgi?id=219 */
        while (pCtxt->nInst++ < MAX_INSTANCE - 1)
        {
            eError = ResourceExhaustionTest_LOAD(pCtxt, cComponentName, pWrapAppData, pWrapCallbacks);
            if (eError != OMX_ErrorNone)
                break;

            eError = ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateIdle);
            if (eError != OMX_ErrorNone)
                break;
        }
        if (eError == OMX_ErrorInsufficientResources)
            eError = OMX_ErrorNone;

        if (pCtxt->nInst == MAX_INSTANCE)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Resources not exhausted - increase max instance\n");
            eError = OMX_ErrorUndefined;
        }
        OMX_CONF_BAIL_IF_ERROR(eError);

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Resources exhausted by instance %d\n", pCtxt->nInst);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Alternatively de-allocate/allocate last 2 instances\n");

        for (i = 0x0; i < MAX_ITERATIONS; i++)
        {
            /* Unload last successfully idled instance */
            pCtxt->nInst--;
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateLoaded));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_UNLOAD(pCtxt));

            /* Load last failing instance */
            pCtxt->nInst++;
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_UNLOAD(pCtxt));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_LOAD(pCtxt, cComponentName, pWrapAppData, pWrapCallbacks));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateIdle));

            /* Unload last successfully idled instance */
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateLoaded));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_UNLOAD(pCtxt));

            /* Load last failing instance */
            pCtxt->nInst--;
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_LOAD(pCtxt, cComponentName, pWrapAppData, pWrapCallbacks));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateIdle));

            pCtxt->nInst++;
        }

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "De-allocate all instances\n");
        while (pCtxt->nInst--)
        {
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateLoaded));
            OMX_CONF_BAIL_IF_ERROR(ResourceExhaustionTest_UNLOAD(pCtxt));
        }

OMX_CONF_TEST_BAIL:
        /* cleanup: return function errors rather than closing errors if appropriate */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Cleanup\n");
        if (OMX_ErrorNone == eError)
        {
            eError = OMX_CONF_CallbackTracerDestroy(pWrapCallbacks, pWrapAppData);
            eError = OMX_Deinit();
        }
        else
        {
            do
            {
                if (pCtxt->hWComp[pCtxt->nInst])
                {
                    ResourceExhaustionTest_TransitionWait(pCtxt, OMX_StateInvalid);
                    ResourceExhaustionTest_DeInitBuffer(pCtxt);
                    ResourceExhaustionTest_UNLOAD(pCtxt);
                }
            }
            while (pCtxt->nInst--);

            OMX_CONF_CallbackTracerDestroy(pWrapCallbacks, pWrapAppData);
            OMX_Deinit();
        }

        OMX_OSAL_EventDestroy(pCtxt->hStateSetEvent);

        return eError;
    }
    /* Main entrypoint into the Incomplete Stop Test */
    OMX_ERRORTYPE OMX_CONF_IncompleteStopTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_PTR pWrappedAppData;
        OMX_CALLBACKTYPE *pWrappedCallbacks;
        OMX_HANDLETYPE hComp, hWrappedComp, hTTComp, hWrappedTTComp;
        OMX_ERRORTYPE  eTemp, eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE oCallbacks;
        ISTDATATYPE oAppData;
        OMX_BOOL bTimedOut;

        /* create state change event */
        OMX_OSAL_EventCreate(&oAppData.hStateChangeEvent);
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_OSAL_EventCreate(&oAppData.hEOSEvent);
        OMX_OSAL_EventReset(oAppData.hEOSEvent);

        /* init component handles */
        hComp = hWrappedComp = hTTComp = hWrappedTTComp = 0;

        oCallbacks.EventHandler    = ISTEventHandler;
        oCallbacks.EmptyBufferDone = StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone  = StubbedFillBufferDone;
        eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR) & oAppData, cComponentName,
                                               &pWrappedCallbacks, &pWrappedAppData);

        /* Initialize OpenMax */
        eError = OMX_Init();

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Creating component under test and tunnel test component.\n");

        /* Acquire component under test handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_GetHandle(&hComp, cComponentName, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hComp, cComponentName, &hWrappedComp));
        oAppData.hCUT = hComp;

        /* Acquire tunnel test component handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_GetTunnelTestComponentHandle(&hTTComp, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hTTComp, "OMX.CONF.tunnel.test", &hWrappedTTComp));

        /* Connect CUT to TTC */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Connecting all ports.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_TTCConnectAllPorts(hWrappedTTComp, hWrappedComp));

        /* Force all CUT ports to be suppliers */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Forcing all component ports to be suppliers.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ForceSuppliers(hWrappedComp, OMX_TRUE));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ForceSuppliers(hWrappedTTComp, OMX_FALSE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transitioning to executing.\n");

        /* transition CUT to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition TTC to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition CUT to executing */
        OMX_CONF_FAIL_IF_ERROR(ISTWaitForState(&oAppData, OMX_StateIdle));
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateExecuting, 0));
        OMX_CONF_FAIL_IF_ERROR(ISTWaitForState(&oAppData, OMX_StateExecuting));

        /* transition TTC to executing  */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateExecuting, 0));

        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_WaitForBufferTraffic(hTTComp));

        /* tell TTC to hold buffers */
        TTCHoldBuffers(hTTComp);

        /* transition CUT to back to idle */
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* wait for change to idle - this must time out */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Holding outstanding buffers, waiting for transition to idle.\n");
        OMX_OSAL_EventWait(oAppData.hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_FAILURE, &bTimedOut);
        if (!bTimedOut)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-ERROR: Transitioned to idle.\n");
            eError = OMX_ErrorUndefined;
        }
        else
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-OK: Didn't transitioned to idle.\n");
        }

        /* tell TTC to release buffers */
        TTCReleaseBuffers(hTTComp);

        /* wait for change to idle - this must succeed */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Released outstanding buffers, waiting for transition to idle.\n");
        OMX_OSAL_EventWait(oAppData.hStateChangeEvent, OMX_CONF_TIMEOUT_EXPECTING_SUCCESS, &bTimedOut);
        if (bTimedOut || oAppData.eState != OMX_StateIdle)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-ERROR: Didn't transition to idle.\n");
            eError = OMX_ErrorUndefined;
        }
        else
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-OK: Transitioned to idle.\n");
        }

OMX_CONF_TEST_FAIL:

        /* Cleanup: Return function errors rather than closing errors if appropriate */

        /* transition CUT to Loaded state */
        if (hWrappedComp)
        {
            OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        /* transition TTC to Loaded state */
        if (hWrappedTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        OMX_CONF_REMEMBER_ERROR(ISTWaitForState(&oAppData, OMX_StateLoaded));

        /* destroy state change event */
        OMX_OSAL_EventDestroy(oAppData.hStateChangeEvent);
        OMX_OSAL_EventDestroy(oAppData.hEOSEvent);

        if (hWrappedComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedComp));
        }

        if (hComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_FreeHandle(hComp));
        }

        if (hTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_FreeTunnelTestComponentHandle(hTTComp));
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedTTComp));
        }

        OMX_CONF_REMEMBER_ERROR(OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData));
        OMX_CONF_REMEMBER_ERROR(OMX_Deinit());

        return eError;
    }
    /* Main entrypoint into the Seeking Component Test */
    OMX_ERRORTYPE OMX_CONF_SeekingComponentTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_TIME_CONFIG_SEEKMODETYPE oSeekMode;
        OMX_TIME_CONFIG_TIMESTAMPTYPE oTimeStamp;
        OMX_PTR pWrappedAppData;
        OMX_CALLBACKTYPE *pWrappedCallbacks;
        OMX_HANDLETYPE hComp, hWrappedComp, hTTComp, hWrappedTTComp;
        OMX_ERRORTYPE  eTemp, eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE oCallbacks;
        SCTDATATYPE oAppData;

        /* create state change event */
        OMX_OSAL_EventCreate(&oAppData.hStateChangeEvent);
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_OSAL_EventCreate(&oAppData.hEOSEvent);
        OMX_OSAL_EventReset(oAppData.hEOSEvent);

        /* init component handles */
        hComp = hWrappedComp = hTTComp = hWrappedTTComp = 0;

        oCallbacks.EventHandler    = SCTEventHandler;
        oCallbacks.EmptyBufferDone = StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone  = StubbedFillBufferDone;
        eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR) & oAppData, cComponentName,
                                               &pWrappedCallbacks, &pWrappedAppData);

        /* Initialize OpenMax */
        eError = OMX_Init();

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Creating component under test and tunnel test component.\n");

        /* Acquire component under test handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_GetHandle(&hComp, cComponentName, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hComp, cComponentName, &hWrappedComp));
        oAppData.hCUT = hComp;

        /* Acquire tunnel test component handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_GetTunnelTestComponentHandle(&hTTComp, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hTTComp, "OMX.CONF.tunnel.test", &hWrappedTTComp));

        /* Set the OnEmptyThisBuffer callback */
        OMX_CONF_SetTTCOnEmptyThisBuffer(hTTComp, SCTOnEmptyThisBuffer);

        /* Connect CUT to TTC */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Connecting all ports.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_TTCConnectAllPorts(hWrappedTTComp, hWrappedComp));

        /* Force all CUT ports to be suppliers */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Forcing all component ports to be suppliers.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ForceSuppliers(hWrappedComp, OMX_TRUE));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ForceSuppliers(hWrappedTTComp, OMX_FALSE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transitioning to executing.\n");

        /* transition CUT to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition TTC to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition CUT to executing */
        OMX_CONF_FAIL_IF_ERROR(SCTWaitForState(&oAppData, OMX_StateIdle));
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateExecuting, 0));
        OMX_CONF_FAIL_IF_ERROR(SCTWaitForState(&oAppData, OMX_StateExecuting));

        /* transition TTC to executing  */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateExecuting, 0));

        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_WaitForBufferTraffic(hTTComp));

        /* Get/Set OMX_IndexConfigTimeSeekMode */
        INIT_CONFIG(oSeekMode);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Confirm support for OMX_IndexConfigTimeSeekMode\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_GetConfig(hComp, OMX_IndexConfigTimeSeekMode, (OMX_PTR)&oSeekMode));
        oSeekMode.eType = OMX_TIME_SeekModeAccurate;
        OMX_CONF_FAIL_IF_ERROR(OMX_SetConfig(hComp, OMX_IndexConfigTimeSeekMode, (OMX_PTR)&oSeekMode));

        /* Get OMX_IndexConfigTimePosition */
        INIT_CONFIG(oTimeStamp);
        oTimeStamp.nPortIndex = 0; /* ignored - but we clear it anyway */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Confirm support for OMX_IndexConfigTimePosition\n");
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-Get the current position (remember it for later).\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_GetConfig(hComp, OMX_IndexConfigTimePosition, (OMX_PTR)&oTimeStamp));

        /* Set OMX_IndexConfigTimePosition */
        /* Wait for the position to move on and then return to it */
        g_StartTimeDetected = OMX_FALSE;
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-Run for a while.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_WaitForBufferTraffic(hTTComp));
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-Seek to the remembered position.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_SetConfig(hComp, OMX_IndexConfigTimePosition, (OMX_PTR)&oTimeStamp));
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "-Run for a while - wait for seek (i.e. a OMX_BUFFERFLAG_STARTTIME).\n");
        OMX_CONF_WaitForBufferTraffic(hTTComp);

        if (g_StartTimeDetected)
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "--OK: Saw OMX_BUFFERFLAG_STARTTIME.\n");
        }
        else
        {
            OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "--ERROR: No OMX_BUFFERFLAG_STARTTIME.\n");
            eError = OMX_ErrorUndefined;
        }

OMX_CONF_TEST_FAIL:

        /* Cleanup: Return function errors rather than closing errors if appropriate */

        /* transition CUT and TTC to Loaded state */
        if (hWrappedComp)
        {
            OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));
        }
        if (hWrappedTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));
            TTCReleaseBuffers(hTTComp);
        }
        if (hWrappedComp)
        {
            OMX_CONF_REMEMBER_ERROR(SCTWaitForState(&oAppData, OMX_StateIdle));
            OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
            OMX_CONF_REMEMBER_ERROR(SCTWaitForState(&oAppData, OMX_StateLoaded));
        }
        if (hWrappedTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        /* destroy state change event */
        OMX_OSAL_EventDestroy(oAppData.hStateChangeEvent);
        OMX_OSAL_EventDestroy(oAppData.hEOSEvent);

        if (hWrappedComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedComp));
        }

        if (hComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_FreeHandle(hComp));
        }

        if (hTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_FreeTunnelTestComponentHandle(hTTComp));
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedTTComp));
        }

        OMX_CONF_REMEMBER_ERROR(OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData));
        OMX_CONF_REMEMBER_ERROR(OMX_Deinit());

        return eError;
    }
    /* Main entrypoint into the Valid Input Output Test */
    OMX_ERRORTYPE OMX_CONF_ValidInputOutputTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_PTR pWrappedAppData;
        OMX_CALLBACKTYPE *pWrappedCallbacks;
        OMX_HANDLETYPE hComp, hWrappedComp, hTTComp, hWrappedTTComp;
        OMX_ERRORTYPE  eTemp, eError = OMX_ErrorNone;
        OMX_CALLBACKTYPE oCallbacks;
        VIOTDATATYPE oAppData;

        /* create state change event */
        OMX_OSAL_EventCreate(&oAppData.hStateChangeEvent);
        OMX_OSAL_EventReset(oAppData.hStateChangeEvent);

        /* init component handles */
        hComp = hWrappedComp = hTTComp = hWrappedTTComp = 0;

        oCallbacks.EventHandler    = VIOTEventHandler;
        oCallbacks.EmptyBufferDone = StubbedEmptyBufferDone;
        oCallbacks.FillBufferDone  = StubbedFillBufferDone;
        eError = OMX_CONF_CallbackTracerCreate(&oCallbacks, (OMX_PTR) & oAppData, cComponentName,
                                               &pWrappedCallbacks, &pWrappedAppData);

        /* Initialize OpenMax */
        eError = OMX_Init();

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Creating component under test and tunnel test component.\n");

        /* Acquire component under test handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_GetHandle(&hComp, cComponentName, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hComp, cComponentName, &hWrappedComp));
        oAppData.hCUT = hComp;

        /* Acquire tunnel test component handle */
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_GetTunnelTestComponentHandle(&hTTComp, pWrappedAppData, pWrappedCallbacks));
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hTTComp, "OMX.CONF.tunnel.test", &hWrappedTTComp));

        /* Connect CUT to TTC */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Connecting all ports.\n");
        OMX_CONF_FAIL_IF_ERROR(OMX_CONF_TTCConnectAllPorts(hWrappedTTComp, hWrappedComp));

        /* transition CUT to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateIdle, 0));

        /* transition TTC to idle */
        OMX_CONF_FAIL_IF_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateIdle, 0));
        OMX_CONF_FAIL_IF_ERROR(VOITWaitForState(&oAppData, OMX_StateIdle));

OMX_CONF_TEST_FAIL:

        /* Cleanup: Return function errors rather than closing errors if appropriate */

        /* transition CUT to Loaded state */
        if (hWrappedComp)
        {
            OMX_OSAL_EventReset(oAppData.hStateChangeEvent);
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        /* transition TTC to Loaded state */
        if (hWrappedTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_SendCommand(hWrappedTTComp, OMX_CommandStateSet, OMX_StateLoaded, 0));
        }

        OMX_CONF_REMEMBER_ERROR(VOITWaitForState(&oAppData, OMX_StateLoaded));

        /* destroy state change event */
        OMX_OSAL_EventDestroy(oAppData.hStateChangeEvent);

        if (hWrappedComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedComp));
        }

        if (hComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_FreeHandle(hComp));
        }

        if (hTTComp)
        {
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_FreeTunnelTestComponentHandle(hTTComp));
            OMX_CONF_REMEMBER_ERROR(OMX_CONF_ComponentTracerDestroy(hWrappedTTComp));
        }

        OMX_CONF_REMEMBER_ERROR(OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData));
        OMX_CONF_REMEMBER_ERROR(OMX_Deinit());

        return eError;
    }
    OMX_ERRORTYPE OMX_CONF_PortCommunicationTest(OMX_IN OMX_STRING cComponentName)
    {
        OMX_ERRORTYPE eError = OMX_ErrorNone;
        OMX_HANDLETYPE hComp  = 0;
        OMX_CALLBACKTYPE sCallbacks;
        PortCommTestCtxt sContext;
        OMX_HANDLETYPE hWrappedComp = 0;
        OMX_CALLBACKTYPE *pWrappedCallbacks;
        OMX_PTR pWrappedAppData;
        PortCommTestCtxt *pCtxt;
        pCtxt = &sContext;
        memset(pCtxt, 0x0, sizeof(PortCommTestCtxt));

        sCallbacks.EventHandler    =  PortCommTest_EventHandler;
        sCallbacks.EmptyBufferDone =  PortCommTest_EmptyBufferDone;
        sCallbacks.FillBufferDone  =  PortCommTest_FillBufferDone;

        eError = OMX_CONF_CallbackTracerCreate(&sCallbacks, (OMX_PTR)pCtxt, cComponentName,
                                               &pWrappedCallbacks, &pWrappedAppData);

        /* initialize events to track callbacks */
        OMX_OSAL_EventCreate(&pCtxt->hStateSetEvent);
        OMX_OSAL_EventReset(pCtxt->hStateSetEvent);
        OMX_OSAL_EventCreate(&pCtxt->hPortDisableEvent);
        OMX_OSAL_EventReset(pCtxt->hPortDisableEvent);
        OMX_OSAL_EventCreate(&pCtxt->hPortEnableEvent);
        OMX_OSAL_EventReset(pCtxt->hPortEnableEvent);
        OMX_OSAL_EventCreate(&pCtxt->hBufDoneEvent);
        OMX_OSAL_EventReset(pCtxt->hBufDoneEvent);
        OMX_OSAL_EventCreate(&pCtxt->hEmptyBufDoneEvent);
        OMX_OSAL_EventReset(pCtxt->hEmptyBufDoneEvent);

        /* Initialize OpenMax */
        eError = OMX_Init();
        OMX_CONF_BAIL_IF_ERROR(eError);

        OMX_CONF_BAIL_IF_ERROR(OMX_GetHandle(&hComp, cComponentName, pWrappedAppData,
                                             pWrappedCallbacks));
        OMX_CONF_BAIL_IF_ERROR(OMX_CONF_ComponentTracerCreate(hComp, cComponentName,
                               &hWrappedComp));
        pCtxt->hWComp = hWrappedComp;

        /* Verify start in Loaded state */
        OMX_CONF_BAIL_IF_ERROR(OMX_GetState(pCtxt->hWComp, &pCtxt->eState));
        if (pCtxt->eState != OMX_StateLoaded)
            OMX_CONF_SET_ERROR_BAIL("Component not in loaded state at init\n", OMX_ErrorUndefined);

        /* detect all audio ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[0], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp, OMX_IndexParamAudioInit,
                                  (OMX_PTR) & pCtxt->sPortParam[0]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i audio ports starting at %i \n",
                       pCtxt->sPortParam[0].nPorts, pCtxt->sPortParam[0].nStartPortNumber);

        /* detect all video ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[1], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp, OMX_IndexParamVideoInit,
                                  (OMX_PTR) & pCtxt->sPortParam[1]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i video ports starting at %i \n",
                       pCtxt->sPortParam[1].nPorts, pCtxt->sPortParam[1].nStartPortNumber);

        /* detect all image ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[2], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp, OMX_IndexParamImageInit,
                                  (OMX_PTR) & pCtxt->sPortParam[2]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i image ports starting at %i \n",
                       pCtxt->sPortParam[2].nPorts, pCtxt->sPortParam[2].nStartPortNumber);

        /* detect all other ports on the component */
        OMX_CONF_INIT_STRUCT(pCtxt->sPortParam[3], OMX_PORT_PARAM_TYPE);
        eError = OMX_GetParameter(pCtxt->hWComp, OMX_IndexParamOtherInit,
                                  (OMX_PTR) & pCtxt->sPortParam[3]);
        if (OMX_ErrorUnsupportedIndex == eError)
            eError = OMX_ErrorNone;
        OMX_CONF_BAIL_IF_ERROR(eError);
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "detected %i other ports starting at %i \n",
                       pCtxt->sPortParam[3].nPorts, pCtxt->sPortParam[3].nStartPortNumber);

        pCtxt->nPorts = pCtxt->sPortParam[0].nPorts + pCtxt->sPortParam[1].nPorts +
                        pCtxt->sPortParam[2].nPorts + pCtxt->sPortParam[3].nPorts;

        /* 3.4.1. Non-Tunneling Setup Test */
        /* TODO: reference core does not take null as port */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Non-Tunneling Setup Test\n");
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_OperateOnPorts(pCtxt, NonTunnelTest));

        /* 3.4.2. Transmit Buffers Between Input and Output Ports and Application */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transmit Test - Client allocates - Full payload\n");
        pCtxt->nBufFactor = 1;
        pCtxt->bClientAllocBuf = OMX_TRUE;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_TransmitTest(pCtxt, OMX_TRUE, OMX_TRUE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transmit Test - Client allocates - Half payload\n");
        pCtxt->nBufFactor = 2;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_TransmitTest(pCtxt, OMX_TRUE, OMX_TRUE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transmit Test - Client allocates - Quarter payload\n");
        pCtxt->nBufFactor = 4;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_TransmitTest(pCtxt, OMX_TRUE, OMX_TRUE));

        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Transmit Test - Component allocates - Full payload\n");
        pCtxt->bClientAllocBuf = OMX_FALSE;
        pCtxt->nBufFactor = 1;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_TransmitTest(pCtxt, OMX_TRUE, OMX_TRUE));

        /* 3.4.3. Port Repack Test */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Repack Test\n");
        pCtxt->bClientAllocBuf = OMX_TRUE;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_RepackTest(pCtxt));

        /* 3.4.4. Port Stop and Restart Test */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Port Stop and Restart Test\n");
        pCtxt->nBufFactor = 1;
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_StopRestartTest(pCtxt));

        /* 3.4.5. Component Pause and Resume Test*/
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Component Pause and Resume Test\n");
        OMX_CONF_BAIL_IF_ERROR(PortCommTest_PauseResume(pCtxt));

OMX_CONF_TEST_BAIL:
        /* cleanup: return function errors rather than closing errors if appropriate */
        OMX_OSAL_Trace(OMX_OSAL_TRACE_INFO, "Cleanup\n");

        if (OMX_ErrorNone == eError)
        {
            if (hWrappedComp)
            {
                eError = OMX_CONF_ComponentTracerDestroy(hWrappedComp);
            }
            if (hComp)
            {
                eError = OMX_FreeHandle(hComp);
            }
            eError = OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData);

            eError = OMX_Deinit();
        }
        else
        {
            PortCommTest_TransitionWait(OMX_StateInvalid, pCtxt);
            PortCommTest_DeInitBuffer(pCtxt);

            if (hWrappedComp)
            {
                OMX_CONF_ComponentTracerDestroy(hWrappedComp);
            }
            if (hComp)
            {
                OMX_FreeHandle(hComp);
            }
            OMX_CONF_CallbackTracerDestroy(pWrappedCallbacks, pWrappedAppData);
            OMX_Deinit();
        }

        OMX_OSAL_EventDestroy(pCtxt->hStateSetEvent);
        OMX_OSAL_EventDestroy(pCtxt->hPortDisableEvent);
        OMX_OSAL_EventDestroy(pCtxt->hPortEnableEvent);
        OMX_OSAL_EventDestroy(pCtxt->hBufDoneEvent);
        OMX_OSAL_EventDestroy(pCtxt->hEmptyBufDoneEvent);

        return eError;
    }