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; }
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; }
/******************************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; }
/******************************Public*Routine******************************\ * OMX_Init() * * Description:This method will initialize the OMX Core. It is the * responsibility of the application to call OMX_Init to ensure the proper * set up of core resources. * * Returns: OMX_NOERROR Successful * * Note * \**************************************************************************/ OMX_ERRORTYPE OMX_Init() { OMX_ERRORTYPE eError = OMX_ErrorNone; TIMM_OSAL_ERRORTYPE eOsalError = TIMM_OSAL_ERR_NONE; eOsalError = TIMM_OSAL_MutexObtain(pCoreInitMutex, TIMM_OSAL_SUSPEND); CORE_assert(eOsalError == TIMM_OSAL_ERR_NONE, OMX_ErrorInsufficientResources, "Mutex lock failed"); count++; if (count == 1) { pthread_mutex_init(&mutex, NULL); eError = OMX_BuildComponentTable(); } eOsalError = TIMM_OSAL_MutexRelease(pCoreInitMutex); CORE_assert(eOsalError == TIMM_OSAL_ERR_NONE, OMX_ErrorInsufficientResources, "Mutex release failed"); EXIT: return eError; }
/**=========================================================================**/ OMX_ERRORTYPE OMX_BASE_CB_ReturnDataNotify(OMX_HANDLETYPE hComponent, OMX_S32 nPortIndex, OMX_BUFFERHEADERTYPE* pBuffer) { OMX_COMPONENTTYPE* pComp ; OMX_BASE_PRIVATETYPE* pBaseComPvt; OMX_BASE_INTERNALTYPE* pBaseComInt; OMX_BASE_PORTTYPE *pPort; OMX_ERRORTYPE tError = OMX_ErrorNone; OMX_BASE_Entering(); OMX_BASE_REQUIRE((hComponent != NULL) && (pBuffer != NULL), OMX_ErrorBadParameter); pComp = (OMX_COMPONENTTYPE *)hComponent; pBaseComPvt = (OMX_BASE_PRIVATETYPE *)pComp->pComponentPrivate; pBaseComInt = (OMX_BASE_INTERNALTYPE*)pBaseComPvt->hOMXBaseInt; pPort = pBaseComInt->ports[nPortIndex]; TIMM_OSAL_MutexObtain(pBaseComPvt->pMutex, TIMM_OSAL_SUSPEND); /* If port is Not-Tunneled, return buffers back to the IL Client by calling * FillBufferDone/EmptyBufferDone depending on the directin of port */ if (!PORT_IS_TUNNEL(pPort)){ TIMM_OSAL_MutexRelease(pBaseComPvt->pMutex); if(pPort->tPortDefParams.eDir == OMX_DirInput) pBaseComInt->tCbInfo.EmptyBufferDone(hComponent, pComp->pApplicationPrivate, pBuffer); else if(pPort->tPortDefParams.eDir == OMX_DirOutput) pBaseComInt->tCbInfo.FillBufferDone(hComponent, pComp->pApplicationPrivate, pBuffer); TIMM_OSAL_MutexObtain(pBaseComPvt->pMutex, TIMM_OSAL_SUSPEND); } /* If port is tunneled,OpenMax components directly pass data buffers among * themselves without returning them to the IL Client, thus it calls * FillThisBuffer/EmptyThisBuffer on to the corresponding tunneled port */ else if (PORT_IS_TUNNEL(pPort) && !PORT_IS_BUFFER_SUPPLIER(pPort)) { TIMM_OSAL_MutexRelease(pBaseComPvt->pMutex); if (pPort->tPortDefParams.eDir == OMX_DirInput) { pBuffer->nOutputPortIndex = pPort->unTunnelPort; pBuffer->nInputPortIndex = pPort->tPortDefParams.nPortIndex; tError = ((OMX_COMPONENTTYPE*)(pPort->hTunnelComp))->FillThisBuffer( pPort->hTunnelComp, pBuffer); } else { pBuffer->nInputPortIndex = pPort->unTunnelPort; pBuffer->nOutputPortIndex = pPort->tPortDefParams.nPortIndex; tError = ((OMX_COMPONENTTYPE*)(pPort->hTunnelComp))->EmptyThisBuffer( pPort->hTunnelComp, pBuffer); } TIMM_OSAL_MutexObtain(pBaseComPvt->pMutex, TIMM_OSAL_SUSPEND); } /* Incase the port is Tunneled and buffer supplier, it calls FTB/ETB on the tunneled port , * but if the tunneled comp is not in executing state which results in * incorrect state operation then the buffer need to be returned to pipe which * will be processed once after the tunneled comp goes to exeucting state */ else if(PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(pPort) && (pPort->bIsPortflushed==OMX_FALSE)) { TIMM_OSAL_MutexRelease(pBaseComPvt->pMutex); if(pPort->tPortDefParams.eDir == OMX_DirInput) { pBuffer->nOutputPortIndex = pPort->unTunnelPort; pBuffer->nInputPortIndex = pPort->tPortDefParams.nPortIndex; tError = ((OMX_COMPONENTTYPE*)(pPort->hTunnelComp))->FillThisBuffer( pPort->hTunnelComp, pBuffer); if(tError != OMX_ErrorNone) TIMM_OSAL_WriteToPipe((pPort->dataPipe), &pBuffer, sizeof(pBuffer), TIMM_OSAL_SUSPEND); } else { pBuffer->nInputPortIndex = pPort->unTunnelPort; pBuffer->nOutputPortIndex = pPort->tPortDefParams.nPortIndex; tError = ((OMX_COMPONENTTYPE*)(pPort->hTunnelComp))->EmptyThisBuffer( pPort->hTunnelComp, pBuffer); if(tError != OMX_ErrorNone) TIMM_OSAL_WriteToPipe((pPort->dataPipe), &pBuffer, sizeof(pBuffer), TIMM_OSAL_SUSPEND); } TIMM_OSAL_MutexObtain(pBaseComPvt->pMutex, TIMM_OSAL_SUSPEND); } TIMM_OSAL_MutexRelease(pBaseComPvt->pMutex); EXIT: OMX_BASE_Exiting(tError); return tError; }