/******************************Public*Routine******************************\
* OMX_FreeHandle()
*
* Description:This method will unload the OMX component pointed by
* OMX_HANDLETYPE. It is the responsibility of the calling method to ensure that
* the Deinit method of the component has been called prior to unloading component
*
* Parameters:
* @param[in] hComponent the component to unload
*
* Returns:    OMX_NOERROR          Successful
*
* Note
*
\**************************************************************************/
OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE hComponent)
{

	OMX_ERRORTYPE eError = OMX_ErrorUndefined;
	OMX_COMPONENTTYPE *pHandle = (OMX_COMPONENTTYPE *) hComponent;
	int i;

	if (pthread_mutex_lock(&mutex) != 0)
	{
		TIMM_OSAL_Error("Core: Error in Mutex lock");
	}

	CORE_require(pHandle != NULL, OMX_ErrorBadParameter, NULL);
	CORE_require(count > 0, OMX_ErrorUndefined,
	    "OMX_FreeHandle called without calling OMX_Init first");

	/* Locate the component handle in the array of handles */
	for (i = 0; i < COUNTOF(pModules); i++)
	{
		if (pComponents[i] == hComponent)
			break;
	}

	CORE_assert(i != COUNTOF(pModules), OMX_ErrorBadParameter, NULL);

	eError = pHandle->ComponentDeInit(hComponent);
	if (eError != OMX_ErrorNone)
	{
		TIMM_OSAL_Error("Error From ComponentDeInit..");
	}

	/* release the component and the component handle */
	dlclose(pModules[i]);
	pModules[i] = NULL;
	free(pComponents[i]);

	pComponents[i] = NULL;
	eError = OMX_ErrorNone;

      EXIT:
	/* The unload is now complete, so set the error code to pass and exit */
	if (pthread_mutex_unlock(&mutex) != 0)
	{
		TIMM_OSAL_Error("Core: Error in Mutex unlock");
	}

	return eError;
}
static OMX_ERRORTYPE ComponentPrivateDeInit(OMX_IN OMX_HANDLETYPE hComponent)
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE;

	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");
	}

	eError = PROXY_ComponentDeInit(hComponent);

      EXIT:
	return eError;
}
/*===============================================================*/
void __attribute__ ((destructor)) Core_Destroy(void)
{
	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;

	eError = TIMM_OSAL_MutexDelete(pCoreInitMutex);
	if (eError != TIMM_OSAL_ERR_NONE)
	{
		TIMM_OSAL_Error("Destruction of default mutex failed");
	}
}
/*===============================================================*/
void __attribute__ ((constructor)) Core_Setup(void)
{
	TIMM_OSAL_ERRORTYPE eError = TIMM_OSAL_ERR_NONE;

	eError = TIMM_OSAL_MutexCreate(&pCoreInitMutex);
	if (eError != TIMM_OSAL_ERR_NONE)
	{
		TIMM_OSAL_Error("Creation of default mutex failed");
	}
}
/******************************Public*Routine******************************\
* OMX_DeInit()
*
* Description:This method will release the resources of the OMX Core.  It is the
* responsibility of the application to call OMX_DeInit to ensure the clean up of these
* resources.
*
* Returns:    OMX_NOERROR          Successful
*
* Note
*
\**************************************************************************/
OMX_ERRORTYPE OMX_Deinit()
{
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE;

	eOsalError = TIMM_OSAL_MutexObtain(pCoreInitMutex, TIMM_OSAL_SUSPEND);
	if (eOsalError != TIMM_OSAL_ERR_NONE)
	{
		TIMM_OSAL_Error("Mutex lock failed");
	}
	/*Returning error none because of OMX spec limitation on error codes that
	   can be returned by OMX_Deinit */
	CORE_assert(count > 0, OMX_ErrorNone,
	    "OMX_Deinit being called without a corresponding OMX_Init");
	count--;

	if (pthread_mutex_lock(&mutex) != 0)
		TIMM_OSAL_Error("Core: Error in Mutex lock");

	if (count == 0)
	{
		if (pthread_mutex_unlock(&mutex) != 0)
			TIMM_OSAL_Error("Core: Error in Mutex unlock");
		if (pthread_mutex_destroy(&mutex) != 0)
		{
			/*printf("%d :: Core: Error in Mutex destroy\n",__LINE__); */
		}
	} else
	{
		if (pthread_mutex_unlock(&mutex) != 0)
			TIMM_OSAL_Error("Core: Error in Mutex unlock");
	}

      EXIT:
	eOsalError = TIMM_OSAL_MutexRelease(pCoreInitMutex);
	if (eOsalError != TIMM_OSAL_ERR_NONE)
	{
		TIMM_OSAL_Error("Mutex release failed");
	}
	return eError;
}
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;
}
void TIMM_OSAL_Free (TIMM_OSAL_PTR pData)
{
    TIMM_OSAL_U32 *pIntPtr = NULL, total_alloc_size;
    TIMM_OSAL_U32 bytes_to_skip;
	xdc_runtime_IHeap_Handle hHeap = NULL;

    if (TIMM_OSAL_NULL == pData) 
	{
        TIMM_OSAL_Error("TIMM_OSAL_Free called on NULL pointer");
        goto EXIT;
    }

    pIntPtr = (TIMM_OSAL_U32 *)pData;
    pIntPtr--;
    total_alloc_size = *pIntPtr--;
    if((*pIntPtr & MEM_CORRUPT_MASK) != MEM_CORRUPT_CHECK_VAL)
    {
        TIMM_OSAL_Error("TIMM_OSAL_Free called with Corrupted pointer");
        goto EXIT;
    }

    bytes_to_skip = (*pIntPtr & MEM_SIZE_MASK);
	pIntPtr--;
	TIMM_OSAL_Memcpy(&hHeap, pIntPtr, sizeof(TIMM_OSAL_U32));
	pIntPtr--;
    pData = pIntPtr - bytes_to_skip/sizeof(TIMM_OSAL_U32);

    Memory_free(hHeap, pData, total_alloc_size);

    /* Memory free was successfull */
    gMallocCounter--;
    gSizeCounter -= total_alloc_size;

EXIT:
    return;
}
/*========================================================*/
void Camera_processfbd(void *threadsArg)
{
	OMX_BUFFERHEADERTYPE *pBuffHeader = NULL;
	OMX_ERRORTYPE err = OMX_ErrorNone;
	TIMM_OSAL_U32 uRequestedEvents, pRetrievedEvents;
	struct port_param *pPortParam;
	int buffer_index, buffer_to_q;
	unsigned int numRemainingIn = 0;
	int ii;
	unsigned int actualSize = 0;
	pthread_t thread_id;
	int policy;
	int rc = 0;
	struct sched_param param;

	thread_id = pthread_self();
	dprintf(0, "New Thread Created\n");
	rc = pthread_getschedparam(thread_id, &policy, &param);
	if (rc != 0)
		dprintf(0, "<Thread> 1 error %d\n", rc);
	printf("<Thread> %d %d\n", policy, param.sched_priority);
	param.sched_priority = 10;
	rc = pthread_setschedparam(thread_id, SCHED_RR /*policy */ , &param);

	if (rc != 0)
		dprintf(0, "<Thread> 2 error %d\n", rc);

	rc = pthread_getschedparam(thread_id, &policy, &param);
	if (rc != 0)
		dprintf(0, "<Thread> 3 error %d\n", rc);
	dprintf(0, "<Thread> %d %d %d %d\n", policy, param.sched_priority,
	    sched_get_priority_min(policy), sched_get_priority_max(policy));

	while (OMX_ErrorNone == err)
	{
		uRequestedEvents = EVENT_CAMERA_FBD;
		dprintf(3, " going to wait for event retreive in thread \n");
		err = TIMM_OSAL_EventRetrieve(myEventIn, uRequestedEvents,
		    TIMM_OSAL_EVENT_OR_CONSUME, &pRetrievedEvents,
		    TIMM_OSAL_SUSPEND);
		if (TIMM_OSAL_ERR_NONE != err)
		{
			dprintf(0, "error = %d pRetrievedEvents\n", err,
			    &pRetrievedEvents);
			TIMM_OSAL_Error("Error in Retrieving event!");
			err = OMX_ErrorUndefined;
		}

		/* Read the number of buffers available in pipe */
		TIMM_OSAL_GetPipeReadyMessageCount(pContext->FBD_pipe,
		    (void *)&numRemainingIn);
		while (numRemainingIn)
		{
			err = TIMM_OSAL_ReadFromPipe(pContext->FBD_pipe,
			    &pBuffHeader, sizeof(pBuffHeader), &actualSize,
			    TIMM_OSAL_SUSPEND);
			if (err != TIMM_OSAL_ERR_NONE)
			{
				printf("\n<Thread>Read from FBD_pipe\
				unsuccessful, going back to wait for event\n");
				break;
			}
			dprintf(2, "\n ReadFromPipe successfully returned\n");

			buffer_index = (int)pBuffHeader->pAppPrivate;
			dprintf(2, "\n buffer_index = %d\n", buffer_index);
			pPortParam =
			    &(pContext->sPortParam[pBuffHeader->
				nOutputPortIndex]);
			dprintf(3, "FillBufferDone for Port = %d\n",
			    (int)pBuffHeader->nOutputPortIndex);
			dprintf(2, "buffer index = %d remaing messages=%d\n",
			    (int)pBuffHeader->pAppPrivate, numRemainingIn);
			dprintf(2, "Filled Length is  = %d ",
			    (int)pBuffHeader->nFilledLen);

			if (pBuffHeader->nOutputPortIndex ==
			    OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW)
			{
				dprintf(3, "Preview port frame Done number =\
					%d\n", (int)pPortParam->nCapFrame);
				pPortParam->nCapFrame++;
				dprintf(3, "\n Before SendbufferToDss() \n");
				buffer_to_q = SendbufferToDss(buffer_index,
				    vid1_fd);
				if (buffer_to_q != 0xFF)
				{
					omx_fillthisbuffer(buffer_to_q,
					    OMX_CAMERA_PORT_VIDEO_OUT_PREVIEW);
				}
			}

			dprintf(2, "\n FillBufferDone \n");
			TIMM_OSAL_GetPipeReadyMessageCount(pContext->FBD_pipe,
			    (void *)&numRemainingIn);
			dprintf(2, " buffer index = %d remaing messages=%d\n",
			    (int)pBuffHeader->pAppPrivate, numRemainingIn);
		}
Exemple #9
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;
}
/* ========================================================================== */
TIMM_OSAL_PTR TIMM_OSAL_MallocExtn(TIMM_OSAL_U32 size,
                                   TIMM_OSAL_BOOL bBlockContiguous,
                                   TIMM_OSAL_U32 unBlockAlignment,
                                   TIMMOSAL_MEM_SEGMENTID tMemSegId,
							       TIMM_OSAL_PTR hHeap)
{

    TIMM_OSAL_PTR pData = TIMM_OSAL_NULL;
    TIMM_OSAL_U32 * pIntPtr = NULL;
    TIMM_OSAL_U32 total_alloc_size;
    TIMM_OSAL_U32 bytes_to_skip;
	Error_Block eb;

    /* If the alignment is 0, 2, 4, 8 or 16*/
    if((MEMORY_HEADER_SIZE >= unBlockAlignment))
    { 
       total_alloc_size = size + MEMORY_HEADER_SIZE;
       bytes_to_skip = 0;
    }
    else
    { 
       /* For 32 byte alignment or more */
       total_alloc_size = size + unBlockAlignment;
       bytes_to_skip = total_alloc_size - (size + MEMORY_HEADER_SIZE);
    }

    pData = Memory_alloc((xdc_runtime_IHeap_Handle)(hHeap), total_alloc_size, 
		                 unBlockAlignment, &eb);

    if (pData == NULL) 
    {
       TIMM_OSAL_Error("Memory Allocation failed!!!");
       pData = TIMM_OSAL_NULL;
    } 
    else 
    {
        /* Memory Allocation was successfull
          Store the size and corruption check symb in
          extra allocated bytes
        */

        gMallocCounter++;
        gSizeCounter += total_alloc_size;

        pIntPtr = (TIMM_OSAL_U32 *)pData;
        /* Because this is U32 pointer */
        pIntPtr = pIntPtr + bytes_to_skip/sizeof(TIMM_OSAL_U32);

	   /*
	   First 4 bytes of the 16 byte header are empty.
	   Next 4 bytes contain the heap handle
	   Next 2 bytes have the magic number for checking corruption
	   Next 2 bytes contain the bytes_to_skip (in case of alignment)
	   Final 4 bytes contain the total allocated size
	   */
	    pIntPtr++;
	    *pIntPtr++ = (TIMM_OSAL_U32)hHeap;
        *pIntPtr++ = (MEM_CORRUPT_CHECK_VAL | bytes_to_skip);
        *pIntPtr++ = total_alloc_size;
        pData = pIntPtr;
    }
    return pData;
}
OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE * pHandle,
    OMX_STRING cComponentName, OMX_PTR pAppData,
    OMX_CALLBACKTYPE * pCallBacks)
{
	static const char prefix[] = "lib";
	static const char postfix[] = ".so";
	OMX_ERRORTYPE(*pComponentInit) (OMX_HANDLETYPE *);
	OMX_ERRORTYPE eError = OMX_ErrorNone;
	OMX_COMPONENTTYPE *componentType;
	int i;
	char buf[sizeof(prefix) + MAXNAMESIZE + sizeof(postfix)];
	const char *pErr = dlerror();
	char *dlError = NULL;
#ifdef CHECK_SECURE_STATE
        int secure_misc_drv_fd,ret;
        OMX_U8 mode, enable=1;
#endif
	if (pthread_mutex_lock(&mutex) != 0)
	{
		TIMM_OSAL_Error("Core: Error in Mutex lock");
	}

	CORE_require(NULL != cComponentName, OMX_ErrorBadParameter, NULL);
	CORE_require(NULL != pHandle, OMX_ErrorBadParameter, NULL);
	CORE_require(NULL != pCallBacks, OMX_ErrorBadParameter, NULL);
	CORE_require(count > 0, OMX_ErrorUndefined,
	    "OMX_GetHandle called without calling OMX_Init first");

	/* Verify that the name is not too long and could cause a crash.  Notice
	 * that the comparison is a greater than or equals.  This is to make
	 * sure that there is room for the terminating NULL at the end of the
	 * name. */
	CORE_require(strlen(cComponentName) < MAXNAMESIZE,
	    OMX_ErrorInvalidComponentName, NULL);

	/* Locate the first empty slot for a component.  If no slots
	 * are available, error out */
	for (i = 0; i < COUNTOF(pModules); i++)
	{
		if (pModules[i] == NULL)
			break;
	}
	CORE_assert(i != COUNTOF(pModules), OMX_ErrorInsufficientResources,
	    NULL);

	/* load the component and check for an error.  If filename is not an
	 * absolute path (i.e., it does not  begin with a "/"), then the
	 * file is searched for in the following locations:
	 *
	 *     The LD_LIBRARY_PATH environment variable locations
	 *     The library cache, /etc/ld.so.cache.
	 *     /lib
	 *     /usr/lib
	 *
	 * If there is an error, we can't go on, so set the error code and exit */
	strcpy(buf, prefix);	/* the lengths are defined herein or have been */
	strcat(buf, cComponentName);	/* checked already, so strcpy and strcat are  */
	strcat(buf, postfix);	/* are safe to use in this context. */

#ifdef CHECK_SECURE_STATE
        //Dont return errors from misc driver to the user if any.
        //Since this affects all usecases, secure and non-secure.
        //Do log the errors though.
        secure_misc_drv_fd = open("/dev/rproc_user", O_SYNC | O_RDONLY);
	if (secure_misc_drv_fd < 0)
	{
		TIMM_OSAL_Error("Can't open misc driver device 0x%x\n", errno);
	}

	ret = read(secure_misc_drv_fd, &mode, sizeof(mode));
	if (ret < 0)
	{
		TIMM_OSAL_Error("Can't read from the misc driver");
	}
        if(mode == enable && strstr(cComponentName,"secure") == NULL)
	{
		TIMM_OSAL_Error("non-secure component not supported in secure mode");
		eError = OMX_ErrorComponentNotFound;
	}
	ret = close(secure_misc_drv_fd);
	if (ret < 0)
	{
		TIMM_OSAL_Error("Can't close the misc driver");
	}
        //Dont allow non-secure usecases if we are in secure state.
        //Else some of the memory regions will be unexpected firewalled.
        //This provides a clean exit in case we are in secure mode.
        if(eError == OMX_ErrorComponentNotFound)
        {
                goto EXIT;
        }
#endif

//#if 0
	pModules[i] = dlopen(buf, RTLD_LAZY | RTLD_GLOBAL);
	if (pModules[i] == NULL)
	{
		dlError = dlerror();
		TIMM_OSAL_Error("Failed because %s", dlError);
		eError = OMX_ErrorComponentNotFound;
		goto EXIT;
	}

	/* Get a function pointer to the "OMX_ComponentInit" function.  If
	 * there is an error, we can't go on, so set the error code and exit */
	pComponentInit = dlsym(pModules[i], "OMX_ComponentInit");
	pErr = dlerror();
	CORE_assert(((pErr == NULL) && (pComponentInit != NULL)),
	    OMX_ErrorInvalidComponent, NULL);
//#endif

	/* We now can access the dll.  So, we need to call the "OMX_ComponentInit"
	 * method to load up the "handle" (which is just a list of functions to
	 * call) and we should be all set.*/
	*pHandle = malloc(sizeof(OMX_COMPONENTTYPE));
	CORE_assert((*pHandle != NULL), OMX_ErrorInsufficientResources,
	    "Malloc of pHandle* failed");

	pComponents[i] = *pHandle;
	componentType = (OMX_COMPONENTTYPE *) * pHandle;
	componentType->nSize = sizeof(OMX_COMPONENTTYPE);

	componentType->nVersion.s.nVersionMajor = 1;
	componentType->nVersion.s.nVersionMinor = 1;
	componentType->nVersion.s.nRevision = 0;
	componentType->nVersion.s.nStep = 0;

	eError = (*pComponentInit) (*pHandle);
//eError = OMX_ComponentInit(*pHandle);
	if (OMX_ErrorNone == eError)
	{
		eError =
		    (componentType->SetCallbacks) (*pHandle, pCallBacks,
		    pAppData);
		CORE_assert(eError == OMX_ErrorNone, eError,
		    "Core: Error returned from component SetCallBack");
	} else
	{
		/* when the component fails to initialize, release the
		   component handle structure */
		free(*pHandle);
		/* mark the component handle as NULL to prevent the caller from
		   actually trying to access the component with it, should they
		   ignore the return code */
		*pHandle = NULL;
		pComponents[i] = NULL;
		dlclose(pModules[i]);
		goto EXIT;
	}
	eError = OMX_ErrorNone;
      EXIT:
	if (pthread_mutex_unlock(&mutex) != 0)
	{
		TIMM_OSAL_Error("Core: Error in Mutex unlock");
	}
	return (eError);
}