OMX_ERRORTYPE Clock::InitComponent() { OMX_ERRORTYPE ret = OMX_ErrorNone; OMX_PARAM_PORTDEFINITIONTYPE sPortDef; OMX_BUFFERSUPPLIERTYPE SupplierType; OMX_U32 i; OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE); sPortDef.eDir = OMX_DirOutput; sPortDef.eDomain = OMX_PortDomainOther; sPortDef.format.other.eFormat = OMX_OTHER_FormatTime; sPortDef.bPopulated = OMX_FALSE; sPortDef.bEnabled = OMX_FALSE; sPortDef.nBufferCountMin = 1; sPortDef.nBufferCountActual = 5; sPortDef.nBufferSize = sizeof(OMX_TIME_MEDIATIMETYPE); SupplierType = OMX_BufferSupplyOutput; for(i=0; i<PORT_NUM; i++) { sPortDef.nPortIndex = i; ports[i]->SetPortDefinition(&sPortDef); ports[i]->SetSupplierType(SupplierType); } if(E_FSL_OSAL_SUCCESS != fsl_osal_mutex_init(&lock, fsl_osal_mutex_normal)) { LOG_ERROR("Create mutext for clock failed.\n"); return OMX_ErrorInsufficientResources; } if(E_FSL_OSAL_SUCCESS != fsl_osal_cond_create(&Cond)) { LOG_ERROR("Create condition variable for clock failed.\n"); return OMX_ErrorInsufficientResources; } OMX_INIT_STRUCT(&sState, OMX_TIME_CONFIG_CLOCKSTATETYPE); sState.eState = CurState = OMX_TIME_ClockStateStopped; RefClock = OMX_TIME_RefClockNone; SegmentStartTime = -1L; bPaused = OMX_FALSE; return ret; }
OMX_ERRORTYPE GMSubtitlePlayer::Init() { if(fsl_osal_sem_init(&pSem, 0, 0) != E_FSL_OSAL_SUCCESS) { LOG_ERROR("Failed to create semphore for subtitle thread.\n"); return OMX_ErrorInsufficientResources; } if(E_FSL_OSAL_SUCCESS != fsl_osal_cond_create(&Cond)) { LOG_ERROR("Create condition variable for subtitle thread.\n"); return OMX_ErrorInsufficientResources; } if(E_FSL_OSAL_SUCCESS != fsl_osal_thread_create(&pThread, NULL, GMSubtitlePlayer::ThreadFunc, this)) { LOG_ERROR("Failed to create subtitle thread.\n"); return OMX_ErrorInsufficientResources; } fsl_osal_memset(&delayedSample, 0, sizeof(delayedSample)); delayedSample.nFilledLen = -1; return OMX_ErrorNone; }