OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_ERRORTYPE dcc_eError = OMX_ErrorNone;
	OMX_COMPONENTTYPE *pHandle = NULL;
	PROXY_COMPONENT_PRIVATE *pComponentPrivate;
    OMX_U32 i = 0, j = 0;
    OMX_PROXY_CAM_PRIVATE* pCamPrv;
	MEMPLUGIN_ERRORTYPE eMemError = MEMPLUGIN_ERROR_NONE;
	pHandle = (OMX_COMPONENTTYPE *) hComponent;
	TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE;
	DOMX_ENTER("_____________________INSIDE CAMERA PROXY"
	    "WRAPPER__________________________\n");
	pHandle->pComponentPrivate = (PROXY_COMPONENT_PRIVATE *)
	    TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE),
	    TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);

	pComponentPrivate =
	    (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
	if (pHandle->pComponentPrivate == NULL)
	{
		DOMX_ERROR(" ERROR IN ALLOCATING PROXY COMPONENT"
		    "PRIVATE STRUCTURE");
		eError = OMX_ErrorInsufficientResources;
		goto EXIT;
	}
	TIMM_OSAL_Memset(pComponentPrivate, 0,
		sizeof(PROXY_COMPONENT_PRIVATE));

	pComponentPrivate->cCompName =
	    TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8),
	    TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);
	/*Copying component Name - this will be picked up in the proxy common */
	assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH);
	TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME,
	    strlen(COMPONENT_NAME) + 1);

        pComponentPrivate->pCompProxyPrv =
            (OMX_PROXY_CAM_PRIVATE *)
            TIMM_OSAL_Malloc(sizeof(OMX_PROXY_CAM_PRIVATE), TIMM_OSAL_TRUE,
            0, TIMMOSAL_MEM_SEGMENT_INT);

        PROXY_assert(pComponentPrivate->pCompProxyPrv != NULL,
            OMX_ErrorInsufficientResources,
            "Could not allocate memory for proxy component private data structure");
        pCamPrv = (OMX_PROXY_CAM_PRIVATE*)pComponentPrivate->pCompProxyPrv;
        TIMM_OSAL_Memset(pComponentPrivate->pCompProxyPrv, 0,
                sizeof(OMX_PROXY_CAM_PRIVATE));

	pComponentPrivate->bMapBuffers = OMX_TRUE;
	/*Calling Proxy Common Init() */
	eError = OMX_ProxyCommonInit(hComponent);
	if (eError != OMX_ErrorNone)
	{
		DOMX_ERROR("\Error in Initializing Proxy");
		TIMM_OSAL_Free(pComponentPrivate->cCompName);
		TIMM_OSAL_Free(pComponentPrivate);
		TIMM_OSAL_Free(pComponentPrivate->pCompProxyPrv);
		goto EXIT;
	}
void* internalMsgRecvThread_func(void* pArgv)
{   //Runs on different thread, which is created in during TCP connection init
    CCommunicationChannelImplementation* msgChan = (CCommunicationChannelImplementation*)pArgv;
    systemMessage_t* pReceiveMessage;
    TIMM_OSAL_ERRORTYPE error = TIMM_OSAL_ERR_NONE;

    while(!msgChan->isClosing() )
    {
        //Recieve message from pipe
        error = msgChan->MsgReceive( (void**)&pReceiveMessage);
        if (TIMM_OSAL_ERR_NONE ==  error)
        {
            // Call MessageEventHandler, Process mesage, Send ACK
            msgChan->consumer->MessageEventHandler(pReceiveMessage);
        } else MMS_IL_PRINT("TIMM_OSAL_ReadFromPipe failed! Error - 0x%08X\n", error);

        //Free message buffer
        if (pReceiveMessage)
        {
            if (pReceiveMessage->pPayload)
            {
                TIMM_OSAL_Free(pReceiveMessage->pPayload);
                pReceiveMessage->pPayload = NULL;
            }
            TIMM_OSAL_Free(pReceiveMessage);
            pReceiveMessage = NULL;
        }// if (pReceiveMessage)

    }//end while(!msgChan->isClosing() )
    printf("internalMsgRecvThread: Channel is closed!\n");
    return NULL;
}
Пример #3
0
TIMM_OSAL_ERRORTYPE TIMM_OSAL_DeleteTask (TIMM_OSAL_PTR pTask)
{
    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE;
    TIMM_OSAL_TASK *pHandle = (TIMM_OSAL_TASK *)pTask;
    TIMM_OSAL_U32 uSleepTime = TASK_MIN_WAIT_TIME;

    if (TIMM_OSAL_NULL == pHandle) 
	{
		bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
        goto EXIT;
    }

    if (pHandle->isCreated != TIMM_OSAL_TRUE) 
	{
		bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
        goto EXIT;
    }
    /*Check the status of the Task*/
    while ( Task_Mode_TERMINATED != Task_getMode ( pHandle->task) ) {
      TIMM_OSAL_SleepTask ( uSleepTime );
      uSleepTime <<= 1;
      if ( uSleepTime >= TASK_MAX_WAIT_TIME) {
        bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
        goto EXIT;
      }
    }
    Task_delete ( &(pHandle->task) );

    TIMM_OSAL_Free (pHandle->stackPtr);
    TIMM_OSAL_Free (pHandle);
EXIT:
    return bReturnStatus;
}
OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_COMPONENTTYPE *pHandle = NULL;
	PROXY_COMPONENT_PRIVATE *pComponentPrivate;
	pHandle = (OMX_COMPONENTTYPE *) hComponent;

	DOMX_DEBUG("___INSISDE VIDEO DECODER PROXY WRAPPER__\n");

	pHandle->pComponentPrivate =
	    (PROXY_COMPONENT_PRIVATE *)
	    TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE,
	    0, TIMMOSAL_MEM_SEGMENT_INT);

	pComponentPrivate =
	    (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
	if (pHandle->pComponentPrivate == NULL)
	{
		DOMX_DEBUG
		    (" ERROR IN ALLOCATING PROXY COMPONENT PRIVATE STRUCTURE");
		eError = OMX_ErrorInsufficientResources;
		goto EXIT;
	}
	pComponentPrivate->cCompName =
	    (OMX_U8 *) TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH *
	    sizeof(OMX_U8), TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);
	if (pComponentPrivate->cCompName == NULL)
	{
		DOMX_DEBUG
		    (" ERROR IN ALLOCATING PROXY COMPONENT NAME STRUCTURE");
		TIMM_OSAL_Free(pComponentPrivate);
		eError = OMX_ErrorInsufficientResources;
		goto EXIT;
	}
	// Copying component Name - this will be picked up in the proxy common
	assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH);
	TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME,
	    strlen(COMPONENT_NAME) + 1);
	eError = OMX_ProxyCommonInit(hComponent);	// Calling Proxy Common Init()

	if (eError != OMX_ErrorNone)
	{
		DOMX_DEBUG("Error in Initializing Proxy");
		TIMM_OSAL_Free(pComponentPrivate->cCompName);
		TIMM_OSAL_Free(pComponentPrivate);
	}
	// Make sure private function to component is always assigned
	// after component init.
#ifdef _OPENCORE
	pHandle->GetParameter = ComponentPrivateGetParameters;
#endif
	pHandle->EmptyThisBuffer = PrearrageEmptyThisBuffer;

	EXIT:
	return eError;
}
OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_COMPONENTTYPE *pHandle = NULL;
	PROXY_COMPONENT_PRIVATE *pComponentPrivate;
	pHandle = (OMX_COMPONENTTYPE *) hComponent;

	DOMX_DEBUG("__INSIDE VP6 VIDEO DECODER PROXY WRAPPER__\n");

	pHandle->pComponentPrivate =
	    (PROXY_COMPONENT_PRIVATE *)
	    TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE), TIMM_OSAL_TRUE,
	    0, TIMMOSAL_MEM_SEGMENT_INT);

	pComponentPrivate = (PROXY_COMPONENT_PRIVATE *)
	    pHandle->pComponentPrivate;
	if (pHandle->pComponentPrivate == NULL)
	{
		DOMX_DEBUG(" ERROR IN ALLOCATING PROXY "
		    "COMPONENT PRIVATE STRUCTURE");
		eError = OMX_ErrorInsufficientResources;
		goto EXIT;
	}
	pComponentPrivate->cCompName =
	    TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8),
	    TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);

	if (pComponentPrivate->cCompName == NULL)
	{
		DOMX_DEBUG(" ERROR IN ALLOCATING PROXY " "COMPONENT NAME");
		eError = OMX_ErrorInsufficientResources;
		goto EXIT;
	}
	/*Copying component Name - this will be picked up in the proxy common */
	assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH);
	TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME,
	    strlen(COMPONENT_NAME) + 1);
	printf("pComponentPrivate->cCompName : %s \n",
	    pComponentPrivate->cCompName);
	eError = OMX_ProxyCommonInit(hComponent);

      EXIT:
	if (eError != OMX_ErrorNone)
	{
		DOMX_DEBUG("Error in Initializing Proxy");
		if (pComponentPrivate)
		{
			if (pComponentPrivate->cCompName)
				TIMM_OSAL_Free(pComponentPrivate->cCompName);
			TIMM_OSAL_Free(pComponentPrivate);
		}
	}

	return eError;
}
MEMPLUGIN_ERRORTYPE MemPlugin_ION_DeInit(void *pMemPluginHandle)
{
    MEMPLUGIN_ERRORTYPE eError = MEMPLUGIN_ERROR_NONE;
    MEMPLUGIN_OBJECT    *pMemPluginHdl = (MEMPLUGIN_OBJECT *)pMemPluginHandle;

    if(pMemPluginHdl->pPluginExtendedInfo != NULL)
    {
        TIMM_OSAL_Free(((MEMPLUGIN_ION_PARAMS *)pMemPluginHdl->pPluginExtendedInfo));
    }
    TIMM_OSAL_Free((MEMPLUGIN_OBJECT *)pMemPluginHandle);
    pMemPluginHandle = NULL;
EXIT:
    return (eError);
}
Пример #7
0
/* ========================================================================== */
TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreCreate(TIMM_OSAL_PTR *pSemaphore,
                                              TIMM_OSAL_U32  uInitCount)
{
	TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
    *pSemaphore = TIMM_OSAL_NULL;

	sem_t *psem = (sem_t *) TIMM_OSAL_Malloc(sizeof(sem_t), 0, 0, 0);

    if(TIMM_OSAL_NULL == psem ) {
        bReturnStatus = TIMM_OSAL_ERR_ALLOC;
		goto EXIT;
	}

	/*Unnamed semaphore*/
	if(SUCCESS != sem_init(psem , 0, uInitCount)) {
		/*TIMM_OSAL_Error("Semaphore Create failed !");*/
		/*goto EXIT;*/
    }
	else {
	    *pSemaphore = (TIMM_OSAL_PTR)psem;
	    bReturnStatus = TIMM_OSAL_ERR_NONE;
	}
EXIT:
    if ((TIMM_OSAL_ERR_NONE != bReturnStatus) && (TIMM_OSAL_NULL != psem)) {
        TIMM_OSAL_Free(psem);
	}
    return bReturnStatus;
}
Пример #8
0
TIMM_OSAL_ERRORTYPE TIMM_OSAL_DeleteTask (TIMM_OSAL_PTR pTask)
{
    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;

    TIMM_OSAL_TASK *pHandle = (TIMM_OSAL_TASK *)pTask;
    void *retVal;

    if ((NULL == pHandle) || (TIMM_OSAL_TRUE != pHandle->isCreated)) {
        /* this task was never created */
		bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
        goto EXIT;
    }
	if(pthread_attr_destroy(&pHandle->ThreadAttr)){
		/*TIMM_OSAL_Error("Delete_Task failed !");*/
		goto EXIT;
	}
    if (pthread_join(pHandle->threadID, &retVal)) {
		/*TIMM_OSAL_Error("Delete_Task failed !");*/
		goto EXIT;
/*	bReturnStatus = TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR, TIMM_OSAL_COMP_TASK, status);*/ /*shm to be done*/
    }
	bReturnStatus = TIMM_OSAL_ERR_NONE;
    TIMM_OSAL_Free(pHandle);
EXIT:
    return bReturnStatus;
}
/*========================================================*/
OMX_ERRORTYPE SampleTest_WriteInBuffers(SampleCompTestCtxt * pContext)
{

	OMX_ERRORTYPE eError = OMX_ErrorNone;
	BufferList *pList;
	OMX_BUFFERHEADERTYPE *pBufHeader;
#ifdef OMX_SAMPLE_TILER_TEST
	OMX_U8 *pTmpBuffer = NULL, *pOrigTmpBuffer = NULL;
#endif
	pList = pContext->pInBufferList;
	while (pList && pList->pBufHdr)
	{
		BUFFERLIST_CLEAR_ENTRY(pList, pBufHeader);
		printf("\nAbout to read from input file\n");
#if defined(OMX_SAMPLE_TILER_TEST)

		//OMX_SAMPLE_BUFFER_SIZE is the total amt of data to be sent in the buffer
		pTmpBuffer =
		    TIMM_OSAL_Malloc(OMX_SAMPLE_BUFFER_SIZE, 0, 0, 0);
		if (pTmpBuffer == NULL)
			OMX_TEST_SET_ERROR_BAIL
			    (OMX_ErrorInsufficientResources,
			    "malloc failed \n");
		pOrigTmpBuffer = pTmpBuffer;

		SampleTest_ReadInputFile(pContext, pTmpBuffer,
		    OMX_SAMPLE_BUFFER_SIZE, pContext->pInputfile);

		Test_Util_Memcpy_1Dto2D(pBufHeader->pBuffer, pTmpBuffer,
		    OMX_SAMPLE_BUFFER_SIZE, OMX_SAMPLE_IN_HEIGHT,
		    OMX_SAMPLE_IN_WIDTH, STRIDE_LINUX);
		pBufHeader->nFilledLen = OMX_SAMPLE_BUFFER_SIZE;

		printf("\nBefore ETB pBufHeader->nInputPortIndex = %d\n",
		    pBufHeader->nInputPortIndex);

		TIMM_OSAL_Free(pOrigTmpBuffer);

#else
		SampleTest_ReadInputFile(pContext, pBufHeader->pBuffer,
		    pBufHeader->nAllocLen, pContext->pInputfile);
		pBufHeader->nFilledLen = pBufHeader->nAllocLen;

#endif
		if (pContext->bEOS == OMX_TRUE)
		{
			pBufHeader->nFlags |= OMX_BUFFERFLAG_EOS;
		}

		eError = OMX_EmptyThisBuffer(pContext->hComp, pBufHeader);

		OMX_TEST_BAIL_IF_ERROR(eError);
	}

      OMX_TEST_BAIL:
	return eError;

}
Пример #10
0
/* ========================================================================== */
static void readMsg(TIMM_OSAL_PTR pBuffer, TIMM_OSAL_U32 nNumBytes)
{
	TIMM_OSAL_U32 actSizeRead = 0;
	static systemMessage_t* tmpMsg = NULL;

	if (!pBuffer){
		SCREXEC_DBG_PRINT("Invalid return buffer supplied!\n");
		return TIMM_OSAL_ERR_PARAMETER;
	}

	if(tmpMsg == NULL){
		if (TIMM_OSAL_ERR_NONE != TIMM_OSAL_ReadFromPipe(STAND1_Script_Execution_PipeO, &tmpMsg, sizeof(systemMessage_t*), &actSizeRead, TIMM_OSAL_SUSPEND)) {
			SCREXEC_DBG_PRINT("TIMM_OSAL_ReadFromPipe failed!\n");
			return TIMM_OSAL_ERR_UNKNOWN;
		}
	}

	if(actSizeRead != sizeof(systemMessage_t*)){
		STAND1_DBG_PRINT("Requested %d bytes but read %d bytes\n", nNumBytes, actSizeRead);
		return TIMM_OSAL_ERR_UNKNOWN;
	}

	if(tmpMsg == NULL){
		SCREXEC_DBG_PRINT("Non-existent message!\n");
		return TIMM_OSAL_ERR_UNKNOWN;
	}

	TIMM_OSAL_Memcpy(pBuffer, tmpMsg, sizeof(systemMessage_t));

	if(tmpMsg->nPayloadSize == 0){
		SCREXEC_DBG_PRINT("Successful message read!\nRead %08X", &tmpMsg);
		TIMM_OSAL_Free(tmpMsg);
		tmpMsg = NULL;
	}else {
		((systemMessage_t*)pBuffer)->pPayload = TIMM_OSAL_MallocExtn(tmpMsg->nPayloadSize, TIMM_OSAL_TRUE, 32, 0, NULL);
		TIMM_OSAL_Memcpy(((systemMessage_t*)pBuffer)->pPayload, tmpMsg->pPayload, tmpMsg->nPayloadSize);

		SCREXEC_DBG_PRINT("Successful message read!\nRead %08X", &tmpMsg);
		TIMM_OSAL_Free(tmpMsg->pPayload);
		TIMM_OSAL_Free(tmpMsg);
		tmpMsg = NULL;
	}

	return TIMM_OSAL_ERR_NONE;
}
/* delete */
void OmxRpc_delete (OmxRpc_Handle *instp)
{
    DOMX_UTL_TRACE_FUNCTION_ENTRY_LEVEL1 ();
    OmxRpc_Instance_finalize ((OmxRpc_Object *) (*instp), 0 /* dont care
                                                             param */ );
    TIMM_OSAL_Free (*instp);
    *((OmxRpc_Handle *) instp) = NULL;
    DOMX_UTL_TRACE_FUNCTION_EXIT_LEVEL1 (OMX_ErrorNone);
}
static OMX_ERRORTYPE ComponentPrivateDeInit(OMX_IN OMX_HANDLETYPE hComponent)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone, eCompReturn = OMX_ErrorNone;
	TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE;
	PROXY_COMPONENT_PRIVATE *pCompPrv;
	OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
	OMX_U32 i, j;
    OMX_PROXY_CAM_PRIVATE* pCamPrv;
    MEMPLUGIN_BUFFER_PARAMS delBuffer_params;
    MEMPLUGIN_BUFFER_PROPERTIES delBuffer_prop;
    RPC_OMX_ERRORTYPE eRPCError = RPC_OMX_ErrorNone;

        MEMPLUGIN_BUFFER_PARAMS_INIT(delBuffer_params);
	pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate;
        if (dcc_flag)
        {
            eOsalError =
                TIMM_OSAL_MutexObtain(cam_mutex, TIMM_OSAL_SUSPEND);
            if (eOsalError != TIMM_OSAL_ERR_NONE)
            {
                    TIMM_OSAL_Error("Mutex Obtain failed");
            }
            numofInstance = numofInstance - 1;

            eOsalError = TIMM_OSAL_MutexRelease(cam_mutex);
            PROXY_assert(eOsalError == TIMM_OSAL_ERR_NONE,
                OMX_ErrorInsufficientResources, "Mutex release failed");
        }
        OMX_CameraVtcFreeMemory(hComponent);


    if(pCompPrv->pCompProxyPrv != NULL) {
        pCamPrv = (OMX_PROXY_CAM_PRIVATE*)pCompPrv->pCompProxyPrv;
        for (i = 0; i < PROXY_MAXNUMOFPORTS; i++) {
            for (j = 0; j < MAX_NUM_INTERNAL_BUFFERS; j++) {
                if (pCamPrv->gComponentBufferAllocation[i][j]) {
                    delBuffer_prop.sBuffer_accessor.pBufferHandle = pCamPrv->gComponentBufferAllocation[i][j];
                    MemPlugin_Free(pCompPrv->pMemPluginHandle,pCompPrv->nMemmgrClientDesc,&delBuffer_params,&delBuffer_prop);
                }
                pCamPrv->gComponentBufferAllocation[i][j] = NULL;
            }
        }

        TIMM_OSAL_Free(pCompPrv->pCompProxyPrv);
        pCompPrv->pCompProxyPrv = NULL;
        pCamPrv = NULL;
    }

	eError = PROXY_ComponentDeInit(hComponent);

      EXIT:
	return eError;
}
OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_ERRORTYPE dcc_eError = OMX_ErrorNone;
	OMX_COMPONENTTYPE *pHandle = NULL;
	PROXY_COMPONENT_PRIVATE *pComponentPrivate;
	pHandle = (OMX_COMPONENTTYPE *) hComponent;
	TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE;
	DOMX_ENTER("_____________________INSIDE CAMERA PROXY"
	    "WRAPPER__________________________\n");
	pHandle->pComponentPrivate = (PROXY_COMPONENT_PRIVATE *)
	    TIMM_OSAL_Malloc(sizeof(PROXY_COMPONENT_PRIVATE),
	    TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);

	pComponentPrivate =
	    (PROXY_COMPONENT_PRIVATE *) pHandle->pComponentPrivate;
	if (pHandle->pComponentPrivate == NULL)
	{
		DOMX_ERROR(" ERROR IN ALLOCATING PROXY COMPONENT"
		    "PRIVATE STRUCTURE");
		eError = OMX_ErrorInsufficientResources;
		goto EXIT;
	}
	pComponentPrivate->cCompName =
	    TIMM_OSAL_Malloc(MAX_COMPONENT_NAME_LENGTH * sizeof(OMX_U8),
	    TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);
	/*Copying component Name - this will be picked up in the proxy common */
	assert(strlen(COMPONENT_NAME) + 1 < MAX_COMPONENT_NAME_LENGTH);
	TIMM_OSAL_Memcpy(pComponentPrivate->cCompName, COMPONENT_NAME,
	    strlen(COMPONENT_NAME) + 1);
	/*Calling Proxy Common Init() */
	eError = OMX_ProxyCommonInit(hComponent);
	if (eError != OMX_ErrorNone)
	{
		DOMX_ERROR("\Error in Initializing Proxy");
		TIMM_OSAL_Free(pComponentPrivate->cCompName);
		TIMM_OSAL_Free(pComponentPrivate);
		goto EXIT;
	}
TIMM_OSAL_ERRORTYPE CCommunicationChannelImplementation::MsgReceive(TIMM_OSAL_PTR* pCurMessage)
{
    TIMM_OSAL_ERRORTYPE error = TIMM_OSAL_ERR_NONE;
    systemMessage_t* message;
    TIMM_OSAL_U32 nMessageSize = 0;

    // Allocate space for message header
    message = (systemMessage_t*)TIMM_OSAL_MallocExtn(DEFAULT_MESSAGE_SIZE, TIMM_OSAL_TRUE, 32,
              TIMMOSAL_MEM_SEGMENT_EXT, NULL);
    //printf("internalMsgRecvThread: Allocate message\n");
    if (!message)
    {
        printf("Cant allocate %d bytes form message header\n", DEFAULT_MESSAGE_SIZE);
        return TIMM_OSAL_ERR_ALLOC;
    }

    *(systemMessage_t **)pCurMessage = message;
    message->pPayload = NULL;
    //TIMM_OSAL_ReadFromPipe doesn't support timeout
    // printf("internalMsgRecvThread: Read from Pipe!\n");
    error = TIMM_OSAL_ReadFromPipe(internalMsgPipe, message, DEFAULT_MESSAGE_SIZE, &nMessageSize,
                                   TIMM_OSAL_SUSPEND);//inifinite timeout
    if (TIMM_OSAL_ERR_NONE != error)
    {
        TIMM_OSAL_Free(message);
        message = NULL;
        printf("Can't read from message pipe\n");
        return error;
    } else if (nMessageSize < sizeof(systemMessage_t))
    {
        TIMM_OSAL_Free(message);
        message = NULL;
        printf("Read data is less than message header size\n");
        return TIMM_OSAL_ERR_MSG_SIZE_MISMATCH;
    }

    return TIMM_OSAL_ERR_NONE;
}
/* ========================================================================== */
TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreCreate(TIMM_OSAL_PTR *pSemaphore,
        TIMM_OSAL_U32  uInitCount)
{
    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE;
    TIMM_OSAL_SEMAPHORE *pHandle = TIMM_OSAL_NULL;
    Semaphore_Params params;
    IArg keyOSALgate;

    *pSemaphore = TIMM_OSAL_NULL;
    pHandle = (TIMM_OSAL_SEMAPHORE *) TIMM_OSAL_Malloc(sizeof(TIMM_OSAL_SEMAPHORE),
              TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_EXT);

    if(TIMM_OSAL_NULL == pHandle)
    {
        bReturnStatus = TIMM_OSAL_ERR_ALLOC;
        goto EXIT;
    }

    /* Generate name of the semaphore */
    keyOSALgate = GateMutexPri_enter(gOSALgate);
    sprintf(pHandle->name, "SEM%lu", gUniqueSemNameCnt++);
    /*To prevent array overflow*/
    if(gUniqueSemNameCnt == 9999)
        gUniqueSemNameCnt = 0;
    GateMutexPri_leave(gOSALgate, keyOSALgate);

    /*Initialize with default values*/
    Semaphore_Params_init(&params);
    params.instance->name = (xdc_String)(pHandle->name);
    params.mode = Semaphore_Mode_COUNTING;

    pHandle->sem = Semaphore_create(uInitCount,&params,NULL);

    if(pHandle->sem == NULL)
    {
        TIMM_OSAL_Free(pHandle);
        bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
    }

    /* Update sem counter */
    gSemCnt++;

    *pSemaphore = (TIMM_OSAL_PTR)pHandle;

EXIT:
    return bReturnStatus;
}
Пример #16
0
/* ========================================================================== */
TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreDelete(TIMM_OSAL_PTR pSemaphore)
{
	TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE;
    sem_t *psem = (sem_t *)pSemaphore;

    if (psem == TIMM_OSAL_NULL ){
		bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
		goto EXIT;
    }
    /* Release the semaphore.  */
	if(SUCCESS != sem_destroy(psem)){
		/*TIMM_OSAL_Error("Semaphore Delete failed !");*/
		bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
	}

	TIMM_OSAL_Free(psem);
EXIT:
    return bReturnStatus;
}
/* ========================================================================== */
TIMM_OSAL_ERRORTYPE TIMM_OSAL_SemaphoreDelete(TIMM_OSAL_PTR pSemaphore)
{
    TIMM_OSAL_SEMAPHORE *pHandle = (TIMM_OSAL_SEMAPHORE *)pSemaphore;
    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE;

    if(pHandle == NULL)
    {
        bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
        goto EXIT;
    }

    /* Delete the semaphore.  */
    Semaphore_delete(&(pHandle->sem));

    /* Update sem counter */
    gSemCnt--;

    TIMM_OSAL_Free(pSemaphore);

EXIT:
    return bReturnStatus;
}
Пример #18
0
TIMM_OSAL_ERRORTYPE TIMM_OSAL_DeletePipe (TIMM_OSAL_PTR pPipe)
{
    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE;

    TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *)pPipe;

	if(TIMM_OSAL_NULL == pHandle) {
		bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
		goto EXIT;
	}

	if (SUCCESS != close(pHandle->pfd[0])) {
    	/*TIMM_OSAL_Error ("Delete_Pipe Read fd failed!!!");*/
	    bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
	}
    if (SUCCESS != close(pHandle->pfd[1])) {
        /*TIMM_OSAL_Error ("Delete_Pipe Write fd failed!!!");*/
	    bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
   	}

    TIMM_OSAL_Free(pHandle);
EXIT:
    return bReturnStatus;
}
Пример #19
0
TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreateTask (TIMM_OSAL_PTR *pTask,
                                          TIMM_OSAL_TaskProc pFunc,
                                          TIMM_OSAL_U32 uArgc,
                                          TIMM_OSAL_PTR pArgv,
                                          TIMM_OSAL_U32 uStackSize,
                                          TIMM_OSAL_U32 uPriority,
                                          TIMM_OSAL_S8 *pName)
{

    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
    TIMM_OSAL_TASK *pHandle = TIMM_OSAL_NULL;
	struct sched_param sched;
    size_t stackSize;
    *pTask = TIMM_OSAL_NULL;
    unsigned int temp = (unsigned int)pFunc;


	/*Task structure allocation*/
    pHandle = (TIMM_OSAL_TASK *) TIMM_OSAL_Malloc(sizeof(TIMM_OSAL_TASK), 0, 0, 0);
    if(pHandle == TIMM_OSAL_NULL) {
        bReturnStatus =  TIMM_OSAL_ERR_ALLOC;
        goto EXIT;
	}

    /* Initial cleaning of the task structure */
    TIMM_OSAL_Memset((TIMM_OSAL_PTR)pHandle, 0, sizeof(TIMM_OSAL_TASK));

	/*Arguments for task*/
	pHandle->uArgc = uArgc;
	pHandle->pArgv = pArgv;

    pHandle->isCreated = TIMM_OSAL_FALSE;


	if(SUCCESS != pthread_attr_init(&pHandle->ThreadAttr)){
		/*TIMM_OSAL_Error("Task Init Attr Init failed!");*/
		goto EXIT;
	}
	/* Updation of the priority and the stack size*/
	
    if(SUCCESS != pthread_attr_getschedparam(&pHandle->ThreadAttr, &sched)){
		/*TIMM_OSAL_Error("Task Init Get Sched Params failed!");*/
		goto EXIT;
    }

    sched.sched_priority = uPriority; /* relative to the default priority */
    if(SUCCESS != pthread_attr_setschedparam(&pHandle->ThreadAttr, &sched)){
		/*TIMM_OSAL_Error("Task Init Set Sched Paramsfailed!");*/
		goto EXIT;
	}

    /*First get the default stack size*/
    if(SUCCESS != pthread_attr_getstacksize(&pHandle->ThreadAttr, &stackSize)){        
		/*TIMM_OSAL_Error("Task Init Set Stack Size failed!");*/
		goto EXIT;
	}

    /*Check if requested stack size is larger than the current default stack size*/
    if(uStackSize > stackSize) {
        stackSize = uStackSize;
        if(SUCCESS != pthread_attr_setstacksize(&pHandle->ThreadAttr, stackSize)){
		    /*TIMM_OSAL_Error("Task Init Set Stack Size failed!");*/
		    goto EXIT;
	    }
    }



	if (SUCCESS != pthread_create(&pHandle->threadID, &pHandle->ThreadAttr, pFunc, pArgv)) {
        /*TIMM_OSAL_Error ("Create_Task failed !");*/
        goto EXIT;
    }


    /* Task was successfully created */
    pHandle->isCreated = TIMM_OSAL_TRUE;
    *pTask = (TIMM_OSAL_PTR )pHandle;
    bReturnStatus = TIMM_OSAL_ERR_NONE;
    /**pTask = (TIMM_OSAL_PTR *)pHandle;*/

EXIT:
/*    if((TIMM_OSAL_ERR_NONE != bReturnStatus) && (TIMM_OSAL_NULL != pHandle)) {
       TIMM_OSAL_Free (pHandle->stackPtr);*/
	if((TIMM_OSAL_ERR_NONE != bReturnStatus)) {
        TIMM_OSAL_Free(pHandle);
    }
    return bReturnStatus;

}
/*========================================================*/
OMX_ERRORTYPE SampleTest_AllocateBuffers(SampleCompTestCtxt * pContext,
    OMX_PARAM_PORTDEFINITIONTYPE * pPortDef)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_U8 *pBuffer = NULL;
	BufferList *pBufferList;
	BufferList *pTemp;
	OMX_BUFFERHEADERTYPE *pBufferHdr;
	OMX_U32 i = 100;
	OMX_COMPONENTTYPE *pComp;

#ifdef OMX_SAMPLE_TILER_TEST
	MemAllocBlock *pBlock = NULL;
	OMX_U32 nNumBlocks = 1;

/*For i/p port allocate 2D packed buffer, for o/p port allocate 1D buffer.
Ideally client should get this from GetParams but this is just a sample test so
values are hardcoded*/

	if (pPortDef->nPortIndex == OMX_SAMPLE_INPUT_PORT)
	{
		nNumBlocks = 2;
		pBlock =
		    TIMM_OSAL_Malloc(sizeof(MemAllocBlock) * nNumBlocks, 0, 0,
		    0);
		TIMM_OSAL_Memset(pBlock, 0, sizeof(MemAllocBlock) * nNumBlocks);
		pBlock[0].dim.area.width = OMX_SAMPLE_IN_2DYWIDTH;
		pBlock[0].dim.area.height = OMX_SAMPLE_IN_2DYHEIGHT;
		pBlock[0].pixelFormat = PIXEL_FMT_8BIT;
		pBlock[1].dim.area.width = OMX_SAMPLE_IN_2DUVWIDTH;
		pBlock[1].dim.area.height = OMX_SAMPLE_IN_2DUVHEIGHT;
		pBlock[1].pixelFormat = PIXEL_FMT_16BIT;
	} else
	{
		nNumBlocks = 1;
		pBlock =
		    TIMM_OSAL_Malloc(sizeof(MemAllocBlock) * nNumBlocks, 0, 0,
		    0);
		TIMM_OSAL_Memset(pBlock, 0, sizeof(MemAllocBlock) * nNumBlocks);
		pBlock[0].dim.len = OMX_SAMPLE_BUFFER_SIZE;
		pBlock[0].pixelFormat = PIXEL_FMT_PAGE;
	}
#endif

	for (i = 0; i < pPortDef->nBufferCountActual; i++)
	{
		pBufferList =
		    (BufferList *) TIMM_OSAL_Malloc(sizeof(BufferList),
		    TIMM_OSAL_TRUE, 0, TIMMOSAL_MEM_SEGMENT_INT);
		if (!pBufferList)
		{
			OMX_TEST_SET_ERROR_BAIL
			    (OMX_ErrorInsufficientResources,
			    "malloc failed \n");
		}

		if (pContext->bClientAllocBuf)
		{

#ifdef OMX_SAMPLE_TILER_TEST
/*For i/p port allocate 2D packed buffer, for o/p port allocate 1D buffer.
Ideally client should get this from GetParams but this is just a sample test so
values are hardcoded*/
			pBuffer = MemMgr_Alloc(pBlock, nNumBlocks);
			printf("\nMemMgr allocated buffer = 0x%x\n", pBuffer);
#else
			pBuffer =
			    (OMX_U8 *) TIMM_OSAL_MallocaBuffer(pPortDef->
			    nBufferSize, pPortDef->bBuffersContiguous,
			    pPortDef->nBufferAlignment);

#endif

			if (!pBufferList)
			{
				OMX_TEST_SET_ERROR_BAIL
				    (OMX_ErrorInsufficientResources,
				    "malloc failed \n");
			}

			printf("\nCalling UseBuf on port %d\n",
			    pPortDef->nPortIndex);
			eError =
			    OMX_UseBuffer(pContext->hComp, &pBufferHdr,
			    pPortDef->nPortIndex, 0, pPortDef->nBufferSize,
			    pBuffer);

			OMX_TEST_BAIL_IF_ERROR(eError);

		} else
		{

			pComp = (OMX_COMPONENTTYPE *) pContext->hComp;
			printf("\nCalling allocate buffer\n");
			eError =
			    OMX_AllocateBuffer(pContext->hComp, &pBufferHdr,
			    pPortDef->nPortIndex, 0, pPortDef->nBufferSize);

			OMX_TEST_BAIL_IF_ERROR(eError);
		}
		printf("\npBufferHdr->nOutputPortIndex = %d\n",
		    pBufferHdr->nOutputPortIndex);
		printf("\npBufferHdr->nInputPortIndex = %d\n",
		    pBufferHdr->nInputPortIndex);
		pBufferList->pNextBuf = NULL;
		pBufferList->pBufHdr = pBufferHdr;
		pBufferList->pOrigBufHdr = pBufferHdr;

		if (pPortDef->eDir == OMX_DirInput)
		{
			printf("\npBufferHdr->nOutputPortIndex = %d\n",
			    pBufferHdr->nOutputPortIndex);
			printf("\npBufferHdr->nInputPortIndex = %d\n",
			    pBufferHdr->nInputPortIndex);
			pBufferHdr->nOutputPortIndex = OMX_NOPORT;
			if (pContext->pInBufferList == NULL)
			{
				pContext->pInBufferList = pBufferList;
			} else
			{
				pTemp = pContext->pInBufferList;
				while (pTemp->pNextBuf)
					pTemp = pTemp->pNextBuf;
				pTemp->pNextBuf = pBufferList;
			}
		} else
		{
			pBufferHdr->nInputPortIndex = OMX_NOPORT;
			printf("\npBufferHdr->nOutputPortIndex = %d\n",
			    pBufferHdr->nOutputPortIndex);
			printf("\npBufferHdr->nInputPortIndex = %d\n",
			    pBufferHdr->nInputPortIndex);
			if (pContext->pOutBufferList == NULL)
			{
				pContext->pOutBufferList = pBufferList;
			} else
			{
				pTemp = pContext->pOutBufferList;
				while (pTemp->pNextBuf)
					pTemp = pTemp->pNextBuf;
				pTemp->pNextBuf = pBufferList;
			}
		}
	}

      OMX_TEST_BAIL:
#ifdef OMX_SAMPLE_TILER_TEST
	if (pBlock != NULL)
		TIMM_OSAL_Free(pBlock);
#endif
	if (eError != OMX_ErrorNone)
	{
		if (pBufferList)
		{
			TIMM_OSAL_Free(pBufferList);
		}
	}

	return eError;
}
/*========================================================*/
OMX_ERRORTYPE SampleTest_DeInitBuffers(SampleCompTestCtxt * pContext)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_U8 *pBuffer;
	BufferList *pBufferList;
	BufferList *pTemp;

	OMX_U32 nRetVal = 0;

	pTemp = pContext->pInBufferList;

	while (pTemp)
	{
		pBufferList = (BufferList *) pTemp;
		pBuffer = (OMX_U8 *) pTemp->pOrigBufHdr->pBuffer;

		printf("\nCalling Free Buffer on port no. %d\n",
		    pTemp->pOrigBufHdr->nInputPortIndex);

		eError =
		    OMX_FreeBuffer(pContext->hComp,
		    pTemp->pOrigBufHdr->nInputPortIndex, pTemp->pOrigBufHdr);
		OMX_TEST_BAIL_IF_ERROR(eError);

                if (pContext->bClientAllocBuf)
                {

#ifdef OMX_SAMPLE_TILER_TEST
                        nRetVal = MemMgr_Free(pBuffer);
                        if (nRetVal)
                        {
                                printf("\nError in MemMgr free\n");
                        }
#else
                        TIMM_OSAL_Free(pBuffer);
#endif
                }

		pTemp = pTemp->pNextBuf;
		if (pBufferList)
			TIMM_OSAL_Free(pBufferList);
	}

	pContext->pInBufferList = NULL;

	pTemp = pContext->pOutBufferList;
	while (pTemp)
	{
		pBufferList = (BufferList *) pTemp;
		pBuffer = (OMX_U8 *) pTemp->pOrigBufHdr->pBuffer;
		printf("\nCalling Free Buffer on port no. %d\n",
		    pTemp->pOrigBufHdr->nOutputPortIndex);

		eError =
		    OMX_FreeBuffer(pContext->hComp,
		    pTemp->pOrigBufHdr->nOutputPortIndex, pTemp->pOrigBufHdr);
		OMX_TEST_BAIL_IF_ERROR(eError);
                if (pContext->bClientAllocBuf)
                {
#ifdef OMX_SAMPLE_TILER_TEST
                        nRetVal = MemMgr_Free(pBuffer);
                        if (nRetVal)
                        {
                                printf("\nError in MemMgr free\n");
                        }
#else
                        TIMM_OSAL_Free(pBuffer);
#endif
                }

		pTemp = pTemp->pNextBuf;
		if (pBufferList)
			TIMM_OSAL_Free(pBufferList);

	}

	pContext->pOutBufferList = NULL;

      OMX_TEST_BAIL:
	return eError;
}
static OMX_ERRORTYPE PrearrageEmptyThisBuffer(OMX_HANDLETYPE hComponent,
	OMX_BUFFERHEADERTYPE * pBufferHdr)
{

	LOGV("Inside PrearrageEmptyThisBuffer");
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	PROXY_COMPONENT_PRIVATE *pCompPrv = NULL;
	OMX_COMPONENTTYPE *hComp = (OMX_COMPONENTTYPE *) hComponent;
	OMX_U8* pBuffer = NULL;
	OMX_U8* pData = NULL;
	OMX_U32 nValue = 0;
	OMX_U32 nWidth = 0;
	OMX_U32 nHeight = 0;
	OMX_U32 nActualCompression = 0;
	OMX_U8* pCSD = NULL;
	OMX_U32 nSize_CSD = 0;

	PROXY_assert(pBufferHdr != NULL, OMX_ErrorBadParameter, NULL);

	if (pBufferHdr->nFlags & OMX_BUFFERFLAG_CODECCONFIG){
		PROXY_assert(hComp->pComponentPrivate != NULL, OMX_ErrorBadParameter, NULL);

		pCompPrv = (PROXY_COMPONENT_PRIVATE *) hComp->pComponentPrivate;
		pBuffer = pBufferHdr->pBuffer;

		VIDDEC_WMV_RCV_header  hBufferRCV;
		VIDDEC_WMV_VC1_header  hBufferVC1;

		LOGV("nFlags: %x", pBufferHdr->nFlags);

		pData = pBufferHdr->pBuffer + 15; /*Position to Width & Height*/
		VIDDEC_LoadDWORD(nValue, pData);
		nWidth = nValue;
		VIDDEC_LoadDWORD(nValue, pData);
		nHeight = nValue;

		pData += 4; /*Position to compression type*/
		VIDDEC_LoadDWORD(nValue, pData);
		nActualCompression = nValue;

		/*Seting pCSD to proper position*/
		pCSD = pBufferHdr->pBuffer;
		pCSD += CSD_POSITION;
		nSize_CSD = pBufferHdr->nFilledLen - CSD_POSITION;

		if(nActualCompression == FOURCC_WMV3){
			hBufferRCV.sStructRCV =
				(VIDDEC_WMV_RCV_struct *)
				TIMM_OSAL_Malloc(sizeof(VIDDEC_WMV_RCV_struct), TIMM_OSAL_TRUE,
				0, TIMMOSAL_MEM_SEGMENT_INT);

			PROXY_assert(hBufferRCV.sStructRCV != NULL,
				OMX_ErrorInsufficientResources, "Malloc failed");

			//From VC-1 spec: Table 265: Sequence Layer Data Structure
			hBufferRCV.sStructRCV->nNumFrames = 0xFFFFFF; /*Infinite frame number*/
			hBufferRCV.sStructRCV->nFrameType = 0xc5; /*0x85 is the value given by ASF to rcv converter*/
			hBufferRCV.sStructRCV->nID = 0x04; /*WMV3*/
			hBufferRCV.sStructRCV->nStructData = 0x018a3106; /*0x06318a01zero fill 0x018a3106*/
			hBufferRCV.sStructRCV->nVertSize = nHeight;
			hBufferRCV.sStructRCV->nHorizSize = nWidth;
			hBufferRCV.sStructRCV->nID2 = 0x0c; /* Fix value */
			hBufferRCV.sStructRCV->nSequenceHdr = 0x00002a9f; /* This value is not provided by parser, so giving a value from a video*/

			LOGV("initial: nStructData: %x", hBufferRCV.sStructRCV->nStructData);
			LOGV("pCSD = %x", (OMX_U32)*pCSD);

			hBufferRCV.sStructRCV->nStructData = (OMX_U32)pCSD[0] << 0  |
				pCSD[1] << 8  |
				pCSD[2] << 16 |
				pCSD[3] << 24;

			LOGV("FINAL: nStructData: %x", hBufferRCV.sStructRCV->nStructData);

			//Copy RCV structure to actual buffer
			assert(pBufferHdr->nFilledLen < pBufferHdr->nAllocLen);
			pBufferHdr->nFilledLen = sizeof(VIDDEC_WMV_RCV_struct);
			TIMM_OSAL_Memcpy(pBufferHdr->pBuffer, (OMX_U8*)hBufferRCV.pBuffer,
				pBufferHdr->nFilledLen);

			//Free aloocated memory
			TIMM_OSAL_Free(hBufferRCV.sStructRCV);
		}
		else if (nActualCompression == FOURCC_WVC1){
			LOGV("VC-1 Advance Profile prearrange");
			OMX_U8* pTempBuf =
				(OMX_U8 *)
				TIMM_OSAL_Malloc(pBufferHdr->nFilledLen, TIMM_OSAL_TRUE,
				0, TIMMOSAL_MEM_SEGMENT_INT);

			PROXY_assert(pTempBuf != NULL,
				OMX_ErrorInsufficientResources, "Malloc failed");

			TIMM_OSAL_Memcpy(pTempBuf, pBufferHdr->pBuffer+52,
				pBufferHdr->nFilledLen-52);
			TIMM_OSAL_Memcpy(pBufferHdr->pBuffer, pTempBuf,
				pBufferHdr->nFilledLen-52);
			pBufferHdr->nFilledLen -= 52;

			TIMM_OSAL_Free(pTempBuf);
		}
	}

	EXIT:
	LOGV("Redirection from PrearrageEmptyThisBuffer to PROXY_EmptyThisBuffer, nFilledLen=%d, nAllocLen=%d", pBufferHdr->nFilledLen, pBufferHdr->nAllocLen);

	return PROXY_EmptyThisBuffer(hComponent, pBufferHdr);
}
Пример #23
0
TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreatePipe (TIMM_OSAL_PTR *pPipe,
                                          TIMM_OSAL_U32  pipeSize,
                                          TIMM_OSAL_U32  messageSize,
                                          TIMM_OSAL_U8   isFixedMessage)
{
    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
    TIMM_OSAL_PIPE *pHandle = TIMM_OSAL_NULL;

    TIMM_OSAL_PIPE *pHandleBackup = TIMM_OSAL_NULL;

    pHandle = (TIMM_OSAL_PIPE *)TIMM_OSAL_Malloc(sizeof(TIMM_OSAL_PIPE), 0, 0, 0);
    TIMM_OSAL_Memset(pHandle, 0x0, sizeof(TIMM_OSAL_PIPE));

    if (TIMM_OSAL_NULL == pHandle) {
        bReturnStatus = TIMM_OSAL_ERR_ALLOC;
        goto EXIT;
    }

	if (SUCCESS != pipe(pHandle->pfd)) {
        /*TIMM_OSAL_Error ("Create_Pipe failed!!!");*/
		goto EXIT;
	}
    
/*AD - This ensures that file descriptors for stdin/out/err are not assigned to 
  component pipes incase those file descriptors are free Normally this if 
  condition will not be true and we'll go directly to the else part*/
    if(pHandle->pfd[0] == 0 || pHandle->pfd[0] == 1 || pHandle->pfd[0] == 2 ||
       pHandle->pfd[1] == 0 || pHandle->pfd[1] == 1 || pHandle->pfd[1] == 2)
    {
        pHandleBackup = (TIMM_OSAL_PIPE *)TIMM_OSAL_Malloc(sizeof(TIMM_OSAL_PIPE), 0, 0, 0);
        TIMM_OSAL_Memset(pHandleBackup, 0x0, sizeof(TIMM_OSAL_PIPE));
        if (TIMM_OSAL_NULL == pHandleBackup) 
        {
            bReturnStatus = TIMM_OSAL_ERR_ALLOC;
            goto EXIT;
        }
/*Allocating the new pipe*/
        if (SUCCESS != pipe(pHandleBackup->pfd)) 
        {
            goto EXIT;
	    }
/*Really crazy case if all 3 reserved file descriptors have been freed up!!
  Should never happen normally*/
	    if(pHandleBackup->pfd[0] == 2 || pHandleBackup->pfd[1] == 2)
	    {
            int pfdDummy[2];
            
	        if (SUCCESS != close(pHandleBackup->pfd[0])) 
            {
	           goto EXIT;
	        }
            if (SUCCESS != close(pHandleBackup->pfd[1])) 
            {
	            goto EXIT;
   	        }
   	        /*Allocating the reserved file descriptor to dummy*/
   	        if(SUCCESS != pipe(pfdDummy))
            {
                goto EXIT;
            }
            /*Now the backup pfd will not get a reserved value*/
            if (SUCCESS != pipe(pHandleBackup->pfd)) 
            {
                goto EXIT;
	        }
	        /*Closing the dummy pfd*/
	        if (SUCCESS != close(pfdDummy[0])) 
            {
	           goto EXIT;
	        }
            if (SUCCESS != close(pfdDummy[1])) 
            {
	            goto EXIT;
   	        }
   	        
        }
/*Closing the previous pipe*/
	    if (SUCCESS != close(pHandle->pfd[0])) 
        {
	        goto EXIT;
	    }
        if (SUCCESS != close(pHandle->pfd[1])) 
        {
	        goto EXIT;
   	    }
   	    TIMM_OSAL_Free(pHandle);
   	    
	    pHandleBackup->pipeSize = pipeSize;
        pHandleBackup->messageSize = messageSize;
	    pHandleBackup->isFixedMessage = isFixedMessage;
        pHandleBackup->messageCount = 0;
        pHandleBackup->totalBytesInPipe = 0; 
        
        *pPipe = (TIMM_OSAL_PTR ) pHandleBackup ;
    }
/*This is the normal case when a reserved file descriptor is not assigned to our pipe*/
    else
    {        
        pHandle->pipeSize = pipeSize;
        pHandle->messageSize = messageSize;
	    pHandle->isFixedMessage = isFixedMessage;
        pHandle->messageCount = 0;
        pHandle->totalBytesInPipe = 0; 

        *pPipe = (TIMM_OSAL_PTR ) pHandle ;
    }

	bReturnStatus = TIMM_OSAL_ERR_NONE;

EXIT:
    if ((TIMM_OSAL_ERR_NONE != bReturnStatus) && (TIMM_OSAL_NULL != pHandle)) {
       TIMM_OSAL_Free(pHandle);
    }
    
    if ((TIMM_OSAL_ERR_NONE != bReturnStatus) && (TIMM_OSAL_NULL != pHandleBackup)) {
       TIMM_OSAL_Free(pHandleBackup);
    }
    return bReturnStatus;
}
Пример #24
0
TIMM_OSAL_ERRORTYPE TIMM_OSAL_WriteToFrontOfPipe (TIMM_OSAL_PTR pPipe,
                                                  void *pMessage,
                                                  TIMM_OSAL_U32 size,
                                                  TIMM_OSAL_S32 timeout)
{

    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_UNKNOWN;
    TIMM_OSAL_U32 lSizeWritten = -1;
    TIMM_OSAL_U32 lSizeRead = -1;
    TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *)pPipe;
    TIMM_OSAL_U8 * tempPtr;

       
    /*First write to this pipe*/
    if(size == 0) {
		bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
		goto EXIT;
	}
	
    lSizeWritten = write(pHandle->pfd[1], pMessage, size);

	if(lSizeWritten != size){
		bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
		goto EXIT;
	}

    /*Update number of messages*/
    pHandle->messageCount++;

    
    if(pHandle->messageCount > 1) {
        /*First allocate memory*/
        tempPtr = (TIMM_OSAL_U8 *)TIMM_OSAL_Malloc(pHandle->totalBytesInPipe, 0, 0, 0);
        
        if(tempPtr == NULL) {
            bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
		    goto EXIT;
        }

        /*Read out of pipe*/
        lSizeRead = read(pHandle->pfd[0], tempPtr, pHandle->totalBytesInPipe);

        /*Write back to pipe*/
        lSizeWritten = write(pHandle->pfd[1], tempPtr, pHandle->totalBytesInPipe);

	    if(lSizeWritten != size){
		    bReturnStatus = TIMM_OSAL_ERR_PARAMETER;
		    goto EXIT;
	    }

        /*Update Total bytes in pipe*/
        pHandle->totalBytesInPipe += size;
    }

     
EXIT:
    TIMM_OSAL_Free(tempPtr);
    
   	return bReturnStatus;

}
Пример #25
0
TIMM_OSAL_ERRORTYPE TIMM_OSAL_CreateTaskExtn (TIMM_OSAL_PTR *pTask,
                                              TIMM_OSAL_TaskProc pFunc,
                                              TIMM_OSAL_U32 uArgc,
                                              TIMM_OSAL_PTR pArgv,
                                              TIMM_OSAL_U32 uStackSize,
                                              TIMM_OSAL_U32 uPriority,
                                              TIMM_OSAL_S8 *pName,
                                              TIMM_OSAL_PTR hStackHeapHandle)
{
    TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE;
 
    TIMM_OSAL_TASK *pHandle = TIMM_OSAL_NULL;
    Task_Params  taskParams; 

    *pTask = TIMM_OSAL_NULL;
    
    if((pFunc == NULL)|| (uPriority > 31))
    {
       bReturnStatus = TIMM_OSAL_ERR_PARAMETER;	
	   goto EXIT;
    }
    
    pHandle = (TIMM_OSAL_TASK *) TIMM_OSAL_Malloc(sizeof(TIMM_OSAL_TASK), 
		                                         TIMM_OSAL_TRUE, 0,
                                                 TIMMOSAL_MEM_SEGMENT_EXT);

    if(TIMM_OSAL_NULL == pHandle)
    {
        bReturnStatus = TIMM_OSAL_ERR_ALLOC;
		goto EXIT;
    }

    /* Initial cleaning of the task structure */
    TIMM_OSAL_Memset((TIMM_OSAL_PTR)pHandle, 0, sizeof (TIMM_OSAL_TASK));

    pHandle->isCreated = TIMM_OSAL_FALSE;

	strncpy((TIMM_OSAL_CHAR *)pHandle->name, (TIMM_OSAL_CHAR *)pName, TASK_NAME_SIZE);
    pHandle->name[TASK_NAME_SIZE] = '\000';
    pHandle->stackSize = uStackSize;
    pHandle->priority  = uPriority;

    /* Allocate memory for task stack */
    pHandle->stackPtr = (TIMM_OSAL_PTR *)TIMM_OSAL_MallocExtn(pHandle->stackSize, 
                                                   TIMM_OSAL_TRUE, 0, 
                                                   TIMMOSAL_MEM_SEGMENT_EXT,
                                                   hStackHeapHandle);
    if (TIMM_OSAL_NULL == pHandle->stackPtr) 
	{
        TIMM_OSAL_Error("TIMM_OSAL_Malloc failed during task stack allocation");
        bReturnStatus = TIMM_OSAL_ERR_ALLOC;
        goto EXIT;
    }
    TIMM_OSAL_Memset(pHandle->stackPtr, 0xFE, pHandle->stackSize);

    Task_Params_init(&taskParams);

    taskParams.arg0 = uArgc;
    taskParams.arg1 = (TIMM_OSAL_U32)pArgv;
    taskParams.priority = uPriority;
    taskParams.stack = pHandle->stackPtr;
    taskParams.stackSize = uStackSize;
	taskParams.instance->name = (xdc_String)pHandle->name;
     
    /* Create the task */
    pHandle->task = Task_create((Task_FuncPtr)pFunc, &taskParams, NULL);

    if (pHandle->task == NULL) 
	{
        bReturnStatus = (TIMM_OSAL_ERRORTYPE)TIMM_OSAL_ERR_CREATE
			                      (TIMM_OSAL_ERR, TIMM_OSAL_COMP_TASK, FALSE);
        goto EXIT;
    }

    /* Task was successfully created */
    pHandle->isCreated = TIMM_OSAL_TRUE;
    
    *pTask = (TIMM_OSAL_PTR *)pHandle;

EXIT:
    if((TIMM_OSAL_ERR_NONE != bReturnStatus) && (TIMM_OSAL_NULL != pHandle)) 
	{
		if(TIMM_OSAL_NULL != pHandle->stackPtr) 
            TIMM_OSAL_Free (pHandle->stackPtr);
        TIMM_OSAL_Free (pHandle);
    }
    return bReturnStatus;
}