OMX_ERRORTYPE Exynos_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent)
{
    OMX_ERRORTYPE                    ret                    = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT        *pExynosComponent       = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST    *pRMComponentWaitList   = NULL;

    FunctionIn();

    Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex);

    pExynosComponent        = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    pRMComponentWaitList    = getRMList(pExynosComponent, gpRMWaitList, NULL);

    ret = removeElementList(&pRMComponentWaitList, pOMXComponent);
    if (ret != OMX_ErrorNone)
        goto EXIT;

    ret = setRMList(pExynosComponent, gpRMWaitList, pRMComponentWaitList);

EXIT:
    Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex);

    FunctionOut();

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent)
{
    OMX_ERRORTYPE                 ret                   = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT     *pExynosComponent      = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST *pRMComponentList      = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST *pRMComponentWaitList  = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST *pComponentTemp        = NULL;
    OMX_COMPONENTTYPE            *pOMXWaitComponent     = NULL;
    int numElem = 0;

    FunctionIn();

    Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex);

    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    pRMComponentList = getRMList(pExynosComponent, gpRMList, NULL);
    if (pRMComponentList == NULL) {
        ret = OMX_ErrorUndefined;
        goto EXIT;
    }

    ret = removeElementList(&pRMComponentList, pOMXComponent);
    if (ret != OMX_ErrorNone)
        goto EXIT;

    ret = setRMList(pExynosComponent, gpRMList, pRMComponentList);
    if (ret != OMX_ErrorNone)
        goto EXIT;

    pRMComponentWaitList    = getRMList(pExynosComponent, gpRMWaitList, NULL);
    pComponentTemp          = pRMComponentWaitList;

    while (pComponentTemp) {
        numElem++;
        pComponentTemp = pComponentTemp->pNext;
    }

    if (numElem > 0) {
        pOMXWaitComponent = pRMComponentWaitList->pOMXStandComp;
        ret = removeElementList(&pRMComponentWaitList, pOMXWaitComponent);
        if (ret != OMX_ErrorNone)
            goto EXIT;

        ret = setRMList(pExynosComponent, gpRMWaitList, pRMComponentWaitList);
        if (ret != OMX_ErrorNone)
            goto EXIT;

        ret = OMX_SendCommand(pOMXWaitComponent, OMX_CommandStateSet, OMX_StateIdle, NULL);
        if (ret != OMX_ErrorNone)
            goto EXIT;
    }

EXIT:
    Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex);

    FunctionOut();

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_ResourceManager_Deinit()
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;
    EXYNOS_OMX_RM_COMPONENT_LIST *pCurrComponent;
    EXYNOS_OMX_RM_COMPONENT_LIST *pNextComponent;

    FunctionIn();

    Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex);

    if (gpVideoDecRMComponentList) {
        pCurrComponent = gpVideoDecRMComponentList;
        while (pCurrComponent != NULL) {
            pNextComponent = pCurrComponent->pNext;
            Exynos_OSAL_Free(pCurrComponent);
            pCurrComponent = pNextComponent;
        }
        gpVideoDecRMComponentList = NULL;
    }
    if (gpVideoDecRMWaitingList) {
        pCurrComponent = gpVideoDecRMWaitingList;
        while (pCurrComponent != NULL) {
            pNextComponent = pCurrComponent->pNext;
            Exynos_OSAL_Free(pCurrComponent);
            pCurrComponent = pNextComponent;
        }
        gpVideoDecRMWaitingList = NULL;
    }

    if (gpVideoEncRMComponentList) {
        pCurrComponent = gpVideoEncRMComponentList;
        while (pCurrComponent != NULL) {
            pNextComponent = pCurrComponent->pNext;
            Exynos_OSAL_Free(pCurrComponent);
            pCurrComponent = pNextComponent;
        }
        gpVideoEncRMComponentList = NULL;
    }
    if (gpVideoEncRMWaitingList) {
        pCurrComponent = gpVideoEncRMWaitingList;
        while (pCurrComponent != NULL) {
            pNextComponent = pCurrComponent->pNext;
            Exynos_OSAL_Free(pCurrComponent);
            pCurrComponent = pNextComponent;
        }
        gpVideoEncRMWaitingList = NULL;
    }

    Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex);

    Exynos_OSAL_MutexTerminate(ghVideoRMComponentListMutex);
    ghVideoRMComponentListMutex = NULL;

    ret = OMX_ErrorNone;
EXIT:
    FunctionOut();

    return ret;
}
OMX_API OMX_ERRORTYPE OMX_APIENTRY Exynos_OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent)
{
    OMX_ERRORTYPE         ret = OMX_ErrorNone;
    EXYNOS_OMX_COMPONENT *currentComponent = NULL;
    EXYNOS_OMX_COMPONENT *deleteComponent  = NULL;

    FunctionIn();

    if ((gInitialized != 1) ||
        (gLoadComponentList == NULL)) {
        ret = OMX_ErrorNotReady;
        goto EXIT;
    }

    if (!hComponent) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }

    Exynos_OSAL_MutexLock(ghLoadComponentListMutex);
    if (gLoadComponentList->pOMXComponent == hComponent) {
        deleteComponent = gLoadComponentList;
        gLoadComponentList = gLoadComponentList->nextOMXComp;
    } else {
        currentComponent = gLoadComponentList;

        while ((currentComponent != NULL) &&
               (currentComponent->nextOMXComp != NULL)) {
            if (currentComponent->nextOMXComp->pOMXComponent == hComponent) {
                deleteComponent = currentComponent->nextOMXComp;
                currentComponent->nextOMXComp = deleteComponent->nextOMXComp;
                break;
            }
            currentComponent = currentComponent->nextOMXComp;
        }

        if (deleteComponent == NULL) {
            ret = OMX_ErrorComponentNotFound;
            Exynos_OSAL_MutexUnlock(ghLoadComponentListMutex);
            goto EXIT;
        }
    }
    Exynos_OSAL_MutexUnlock(ghLoadComponentListMutex);

    Exynos_OMX_ComponentUnload(deleteComponent);
    Exynos_OSAL_Free(deleteComponent);

EXIT:
    FunctionOut();

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_ResourceManager_Deinit()
{
    OMX_ERRORTYPE                    ret            = OMX_ErrorNone;
    EXYNOS_OMX_RM_COMPONENT_LIST    *pCurrComponent = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST    *pNextComponent = NULL;
    int i = 0;

    FunctionIn();

    Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex);

    for (i = 0; i < RESOURCE_MAX; i++) {
        if (gpRMList[i]) {
            pCurrComponent = gpRMList[i];
            while (pCurrComponent != NULL) {
                pNextComponent = pCurrComponent->pNext;
                Exynos_OSAL_Free(pCurrComponent);
                pCurrComponent = pNextComponent;
            }
            gpRMList[i] = NULL;
        }

        if (gpRMWaitList[i]) {
            pCurrComponent = gpRMWaitList[i];
            while (pCurrComponent != NULL) {
                pNextComponent = pCurrComponent->pNext;
                Exynos_OSAL_Free(pCurrComponent);
                pCurrComponent = pNextComponent;
            }
            gpRMWaitList[i] = NULL;
        }
    }

    Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex);

    Exynos_OSAL_MutexTerminate(ghVideoRMComponentListMutex);
    ghVideoRMComponentListMutex = NULL;

    ret = OMX_ErrorNone;

EXIT:
    FunctionOut();

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_ResourceManager_Init()
{
    OMX_ERRORTYPE ret = OMX_ErrorNone;

    FunctionIn();

    ret = Exynos_OSAL_MutexCreate(&ghVideoRMComponentListMutex);

    if (ret == OMX_ErrorNone) {
        Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex);
        Exynos_OSAL_Memset(gpRMList, NULL, (sizeof(EXYNOS_OMX_RM_COMPONENT_LIST*) * RESOURCE_MAX));
        Exynos_OSAL_Memset(gpRMWaitList, NULL, (sizeof(EXYNOS_OMX_RM_COMPONENT_LIST*) * RESOURCE_MAX));
        Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex);
    }

    FunctionOut();

    return ret;
}
コード例 #7
0
OMX_ERRORTYPE Exynos_OMX_OutputBufferReturn(OMX_COMPONENTTYPE *pOMXComponent, OMX_BUFFERHEADERTYPE* bufferHeader)
{
    OMX_ERRORTYPE             ret = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    EXYNOS_OMX_BASEPORT      *pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
    OMX_U32                   i = 0;

    Exynos_OSAL_MutexLock(pExynosPort->hPortMutex);
    for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) {
        if (bufferHeader == pExynosPort->extendBufferHeader[i].OMXBufferHeader) {
            pExynosPort->extendBufferHeader[i].bBufferInOMX = OMX_FALSE;
            break;
        }
    }

    Exynos_OSAL_MutexUnlock(pExynosPort->hPortMutex);
    pExynosComponent->pCallbacks->FillBufferDone(pOMXComponent, pExynosComponent->callbackData, bufferHeader);

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_Out_WaitForResource(OMX_COMPONENTTYPE *pOMXComponent)
{
    OMX_ERRORTYPE             ret = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;

    FunctionIn();

    Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex);

    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    if (pExynosComponent->codecType == HW_VIDEO_DEC_CODEC)
        ret = removeElementList(&gpVideoDecRMWaitingList, pOMXComponent);
    else if (pExynosComponent->codecType == HW_VIDEO_ENC_CODEC)
        ret = removeElementList(&gpVideoEncRMWaitingList, pOMXComponent);

    Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex);

    FunctionOut();

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent)
{
    OMX_ERRORTYPE                 ret                   = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT     *pExynosComponent      = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST *pRMComponentList      = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST *pComponentTemp        = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST *pComponentCandidate   = NULL;
    int numElem       = 0;
    int lowCompDetect = 0;
    int maxResource   = 0;

    FunctionIn();

    Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex);

    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    pRMComponentList = getRMList(pExynosComponent, gpRMList, &maxResource);

    pComponentTemp = pRMComponentList;
    if (pComponentTemp != NULL) {
        while (pComponentTemp) {
            numElem++;
            pComponentTemp = pComponentTemp->pNext;
        }
    } else {
        numElem = 0;
    }

    if (numElem >= maxResource) {
        lowCompDetect = searchLowPriority(pRMComponentList,
                                          pExynosComponent->compPriority.nGroupPriority,
                                          &pComponentCandidate);
        if (lowCompDetect <= 0) {
            ret = OMX_ErrorInsufficientResources;
            goto EXIT;
        } else {
            ret = removeComponent(pComponentCandidate->pOMXStandComp);
            if (ret != OMX_ErrorNone) {
                ret = OMX_ErrorInsufficientResources;
                goto EXIT;
            } else {
                ret = removeElementList(&pRMComponentList, pComponentCandidate->pOMXStandComp);
                if (ret != OMX_ErrorNone)
                    goto EXIT;

                ret = addElementList(&pRMComponentList, pOMXComponent);
                if (ret != OMX_ErrorNone)
                    goto EXIT;
            }
        }
    } else {
        ret = addElementList(&pRMComponentList, pOMXComponent);
        if (ret != OMX_ErrorNone)
            goto EXIT;
    }

    ret = setRMList(pExynosComponent, gpRMList, pRMComponentList);
    if (ret != OMX_ErrorNone)
        goto EXIT;

    ret = OMX_ErrorNone;

EXIT:
    Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex);

    FunctionOut();

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_Release_Resource(OMX_COMPONENTTYPE *pOMXComponent)
{
    OMX_ERRORTYPE                 ret = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT     *pExynosComponent = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL;
    OMX_COMPONENTTYPE            *pOMXWaitComponent = NULL;
    int numElem = 0;

    FunctionIn();

    Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex);

    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;

    if (pExynosComponent->codecType == HW_VIDEO_DEC_CODEC) {
        pComponentTemp = gpVideoDecRMWaitingList;
        if (gpVideoDecRMComponentList == NULL) {
            ret = OMX_ErrorUndefined;
            goto EXIT;
        }

        ret = removeElementList(&gpVideoDecRMComponentList, pOMXComponent);
        if (ret != OMX_ErrorNone) {
            ret = OMX_ErrorUndefined;
            goto EXIT;
        }
        while (pComponentTemp) {
            numElem++;
            pComponentTemp = pComponentTemp->pNext;
        }
        if (numElem > 0) {
            pOMXWaitComponent = gpVideoDecRMWaitingList->pOMXStandComp;
            removeElementList(&gpVideoDecRMWaitingList, pOMXWaitComponent);
            ret = OMX_SendCommand(pOMXWaitComponent, OMX_CommandStateSet, OMX_StateIdle, NULL);
            if (ret != OMX_ErrorNone) {
                goto EXIT;
            }
        }
    } else if (pExynosComponent->codecType == HW_VIDEO_ENC_CODEC) {
        pComponentTemp = gpVideoEncRMWaitingList;
        if (gpVideoEncRMComponentList == NULL) {
            ret = OMX_ErrorUndefined;
            goto EXIT;
        }

        ret = removeElementList(&gpVideoEncRMComponentList, pOMXComponent);
        if (ret != OMX_ErrorNone) {
            ret = OMX_ErrorUndefined;
            goto EXIT;
        }
        while (pComponentTemp) {
            numElem++;
            pComponentTemp = pComponentTemp->pNext;
        }
        if (numElem > 0) {
            pOMXWaitComponent = gpVideoEncRMWaitingList->pOMXStandComp;
            removeElementList(&gpVideoEncRMWaitingList, pOMXWaitComponent);
            ret = OMX_SendCommand(pOMXWaitComponent, OMX_CommandStateSet, OMX_StateIdle, NULL);
            if (ret != OMX_ErrorNone) {
                goto EXIT;
            }
        }
    }

EXIT:

    Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex);

    FunctionOut();

    return ret;
}
OMX_ERRORTYPE Exynos_OMX_Get_Resource(OMX_COMPONENTTYPE *pOMXComponent)
{
    OMX_ERRORTYPE                 ret = OMX_ErrorNone;
    EXYNOS_OMX_BASECOMPONENT     *pExynosComponent = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST *pComponentTemp = NULL;
    EXYNOS_OMX_RM_COMPONENT_LIST *pComponentCandidate = NULL;
    int numElem = 0;
    int lowCompDetect = 0;

    FunctionIn();

    Exynos_OSAL_MutexLock(ghVideoRMComponentListMutex);

    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;

    if (pExynosComponent->codecType == HW_VIDEO_DEC_CODEC) {
        pComponentTemp = gpVideoDecRMComponentList;
        if (pComponentTemp != NULL) {
            while (pComponentTemp) {
                numElem++;
                pComponentTemp = pComponentTemp->pNext;
            }
        } else {
            numElem = 0;
        }
        if (numElem >= MAX_RESOURCE_VIDEO_DEC) {
            lowCompDetect = searchLowPriority(gpVideoDecRMComponentList, pExynosComponent->compPriority.nGroupPriority, &pComponentCandidate);
            if (lowCompDetect <= 0) {
                ret = OMX_ErrorInsufficientResources;
                goto EXIT;
            } else {
                ret = removeComponent(pComponentCandidate->pOMXStandComp);
                if (ret != OMX_ErrorNone) {
                    ret = OMX_ErrorInsufficientResources;
                    goto EXIT;
                } else {
                    ret = removeElementList(&gpVideoDecRMComponentList, pComponentCandidate->pOMXStandComp);
                    ret = addElementList(&gpVideoDecRMComponentList, pOMXComponent);
                    if (ret != OMX_ErrorNone) {
                        ret = OMX_ErrorInsufficientResources;
                        goto EXIT;
                    }
                }
            }
        } else {
            ret = addElementList(&gpVideoDecRMComponentList, pOMXComponent);
            if (ret != OMX_ErrorNone) {
                ret = OMX_ErrorInsufficientResources;
                goto EXIT;
            }
        }
    } else if (pExynosComponent->codecType == HW_VIDEO_ENC_CODEC) {
        pComponentTemp = gpVideoEncRMComponentList;
        if (pComponentTemp != NULL) {
            while (pComponentTemp) {
                numElem++;
                pComponentTemp = pComponentTemp->pNext;
            }
        } else {
            numElem = 0;
        }
        if (numElem >= MAX_RESOURCE_VIDEO_ENC) {
            lowCompDetect = searchLowPriority(gpVideoEncRMComponentList, pExynosComponent->compPriority.nGroupPriority, &pComponentCandidate);
            if (lowCompDetect <= 0) {
                ret = OMX_ErrorInsufficientResources;
                goto EXIT;
            } else {
                ret = removeComponent(pComponentCandidate->pOMXStandComp);
                if (ret != OMX_ErrorNone) {
                    ret = OMX_ErrorInsufficientResources;
                    goto EXIT;
                } else {
                    ret = removeElementList(&gpVideoEncRMComponentList, pComponentCandidate->pOMXStandComp);
                    ret = addElementList(&gpVideoEncRMComponentList, pOMXComponent);
                    if (ret != OMX_ErrorNone) {
                        ret = OMX_ErrorInsufficientResources;
                        goto EXIT;
                    }
                }
            }
        } else {
            ret = addElementList(&gpVideoEncRMComponentList, pOMXComponent);
            if (ret != OMX_ErrorNone) {
                ret = OMX_ErrorInsufficientResources;
                goto EXIT;
            }
        }
    }
    ret = OMX_ErrorNone;

EXIT:

    Exynos_OSAL_MutexUnlock(ghVideoRMComponentListMutex);

    FunctionOut();

    return ret;
}
OMX_API OMX_ERRORTYPE OMX_APIENTRY Exynos_OMX_GetHandle(
    OMX_OUT OMX_HANDLETYPE *pHandle,
    OMX_IN  OMX_STRING cComponentName,
    OMX_IN  OMX_PTR pAppData,
    OMX_IN  OMX_CALLBACKTYPE *pCallBacks)
{
    OMX_ERRORTYPE         ret = OMX_ErrorNone;
    EXYNOS_OMX_COMPONENT *loadComponent;
    EXYNOS_OMX_COMPONENT *currentComponent;
    unsigned int i = 0;

    FunctionIn();

    if (gInitialized != 1) {
        ret = OMX_ErrorNotReady;
        goto EXIT;
    }

    if ((pHandle == NULL) || (cComponentName == NULL) || (pCallBacks == NULL)) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "ComponentName : %s", cComponentName);

    for (i = 0; i < gComponentNum; i++) {
        if (Exynos_OSAL_Strcmp(cComponentName, gComponentList[i].component.componentName) == 0) {
            loadComponent = Exynos_OSAL_Malloc(sizeof(EXYNOS_OMX_COMPONENT));
            Exynos_OSAL_Memset(loadComponent, 0, sizeof(EXYNOS_OMX_COMPONENT));

            Exynos_OSAL_Strcpy(loadComponent->libName, gComponentList[i].libName);
            Exynos_OSAL_Strcpy(loadComponent->componentName, gComponentList[i].component.componentName);
            ret = Exynos_OMX_ComponentLoad(loadComponent);
            if (ret != OMX_ErrorNone) {
                Exynos_OSAL_Free(loadComponent);
                Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
                goto EXIT;
            }

            ret = loadComponent->pOMXComponent->SetCallbacks(loadComponent->pOMXComponent, pCallBacks, pAppData);
            if (ret != OMX_ErrorNone) {
                Exynos_OMX_ComponentUnload(loadComponent);
                Exynos_OSAL_Free(loadComponent);
                Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__);
                goto EXIT;
            }

            Exynos_OSAL_MutexLock(ghLoadComponentListMutex);
            if (gLoadComponentList == NULL) {
                gLoadComponentList = loadComponent;
            } else {
                currentComponent = gLoadComponentList;
                while (currentComponent->nextOMXComp != NULL) {
                    currentComponent = currentComponent->nextOMXComp;
                }
                currentComponent->nextOMXComp = loadComponent;
            }
            Exynos_OSAL_MutexUnlock(ghLoadComponentListMutex);

            *pHandle = loadComponent->pOMXComponent;
            ret = OMX_ErrorNone;
            Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Exynos_OMX_GetHandle : %s", "OMX_ErrorNone");
            goto EXIT;
        }
    }

    ret = OMX_ErrorComponentNotFound;

EXIT:
    FunctionOut();

    return ret;
}
コード例 #13
0
OMX_ERRORTYPE Exynos_OMX_FillThisBuffer(
    OMX_IN OMX_HANDLETYPE        hComponent,
    OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
{
    OMX_ERRORTYPE           ret = OMX_ErrorNone;
    OMX_COMPONENTTYPE     *pOMXComponent = NULL;
    EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
    EXYNOS_OMX_BASEPORT      *pExynosPort = NULL;
    OMX_BOOL               findBuffer = OMX_FALSE;
    EXYNOS_OMX_MESSAGE       *message;
    OMX_U32                i = 0;

    FunctionIn();

    if (hComponent == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
    ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }

    if (pOMXComponent->pComponentPrivate == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
    if (pExynosComponent->currentState == OMX_StateInvalid) {
        ret = OMX_ErrorInvalidState;
        goto EXIT;
    }

    if (pBuffer == NULL) {
        ret = OMX_ErrorBadParameter;
        goto EXIT;
    }
    if (pBuffer->nOutputPortIndex != OUTPUT_PORT_INDEX) {
        ret = OMX_ErrorBadPortIndex;
        goto EXIT;
    }

    ret = Exynos_OMX_Check_SizeVersion(pBuffer, sizeof(OMX_BUFFERHEADERTYPE));
    if (ret != OMX_ErrorNone) {
        goto EXIT;
    }

    if ((pExynosComponent->currentState != OMX_StateIdle) &&
        (pExynosComponent->currentState != OMX_StateExecuting) &&
        (pExynosComponent->currentState != OMX_StatePause)) {
        ret = OMX_ErrorIncorrectStateOperation;
        goto EXIT;
    }

    pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
    if ((!CHECK_PORT_ENABLED(pExynosPort)) ||
        ((CHECK_PORT_BEING_FLUSHED(pExynosPort) || CHECK_PORT_BEING_DISABLED(pExynosPort)) &&
        (!CHECK_PORT_TUNNELED(pExynosPort) || !CHECK_PORT_BUFFER_SUPPLIER(pExynosPort))) ||
        ((pExynosComponent->transientState == EXYNOS_OMX_TransStateExecutingToIdle) &&
        (CHECK_PORT_TUNNELED(pExynosPort) && !CHECK_PORT_BUFFER_SUPPLIER(pExynosPort)))) {
        ret = OMX_ErrorIncorrectStateOperation;
        goto EXIT;
    }

    Exynos_OSAL_MutexLock(pExynosPort->hPortMutex);
    for (i = 0; i < pExynosPort->portDefinition.nBufferCountActual; i++) {
        if (pBuffer == pExynosPort->extendBufferHeader[i].OMXBufferHeader) {
            pExynosPort->extendBufferHeader[i].bBufferInOMX = OMX_TRUE;
            findBuffer = OMX_TRUE;
            break;
        }
    }

    if (findBuffer == OMX_FALSE) {
        ret = OMX_ErrorBadParameter;
        Exynos_OSAL_MutexUnlock(pExynosPort->hPortMutex);
        goto EXIT;
    }

    message = Exynos_OSAL_Malloc(sizeof(EXYNOS_OMX_MESSAGE));
    if (message == NULL) {
        ret = OMX_ErrorInsufficientResources;
        Exynos_OSAL_MutexUnlock(pExynosPort->hPortMutex);
        goto EXIT;
    }
    message->messageType = EXYNOS_OMX_CommandFillBuffer;
    message->messageParam = (OMX_U32) i;
    message->pCmdData = (OMX_PTR)pBuffer;

    ret = Exynos_OSAL_Queue(&pExynosPort->bufferQ, (void *)message);
    if (ret != 0) {
        ret = OMX_ErrorUndefined;
        Exynos_OSAL_MutexUnlock(pExynosPort->hPortMutex);
        goto EXIT;
    }

    ret = Exynos_OSAL_SemaphorePost(pExynosPort->bufferSemID);
    Exynos_OSAL_MutexUnlock(pExynosPort->hPortMutex);

EXIT:
    FunctionOut();

    return ret;
}