void CWelsTaskManageBase::Uninit() { DestroyTasks(); WELS_DELETE_OP (m_pThreadPool); delete m_cTaskList; WelsEventClose (&m_hTaskEvent); }
void CWelsTaskManageBase::Uninit() { DestroyTasks(); WELS_DELETE_OP (m_pThreadPool); for (int32_t iDid = 0; iDid < MAX_DEPENDENCY_LAYER; iDid++) { delete m_cEncodingTaskList[iDid]; delete m_cPreEncodingTaskList[iDid]; } WelsEventClose (&m_hTaskEvent); }
void ReleaseMtResource (sWelsEncCtx** ppCtx) { SWelsSliceBs* pSliceB = NULL; SSliceThreading* pSmt = NULL; CMemoryAlign* pMa = NULL; int32_t iIdx = 0; int32_t iThreadNum = 0; int16_t uiSliceNum = 0; if (NULL == ppCtx || NULL == *ppCtx) return; pMa = (*ppCtx)->pMemAlign; uiSliceNum = (*ppCtx)->iMaxSliceCount; iThreadNum = (*ppCtx)->pSvcParam->iCountThreadsNum; pSmt = (*ppCtx)->pSliceThreading; if (NULL == pSmt) return; char ename[SEM_NAME_MAX] = {0}; while (iIdx < iThreadNum) { // length of semaphore name should be system constrained at least on mac 10.7 WelsSnprintf (ename, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); WelsEventClose (&pSmt->pExitEncodeEvent[iIdx], ename); WelsSnprintf (ename, SEM_NAME_MAX, "tm%d%s", iIdx, pSmt->eventNamespace); WelsEventClose (&pSmt->pThreadMasterEvent[iIdx], ename); WelsSnprintf (ename, SEM_NAME_MAX, "sc%d%s", iIdx, pSmt->eventNamespace); WelsEventClose (&pSmt->pSliceCodedEvent[iIdx], ename); WelsSnprintf (ename, SEM_NAME_MAX, "rc%d%s", iIdx, pSmt->eventNamespace); WelsEventClose (&pSmt->pReadySliceCodingEvent[iIdx], ename); WelsSnprintf (ename, SEM_NAME_MAX, "ud%d%s", iIdx, pSmt->eventNamespace); WelsEventClose (&pSmt->pUpdateMbListEvent[iIdx], ename); WelsSnprintf (ename, SEM_NAME_MAX, "fu%d%s", iIdx, pSmt->eventNamespace); WelsEventClose (&pSmt->pFinUpdateMbListEvent[iIdx], ename); ++ iIdx; } WelsSnprintf (ename, SEM_NAME_MAX, "scm%s", pSmt->eventNamespace); WelsEventClose (&pSmt->pSliceCodedMasterEvent, ename); WelsMutexDestroy (&pSmt->mutexSliceNumUpdate); WelsMutexDestroy (&pSmt->mutexThreadBsBufferUsage); WelsMutexDestroy (& ((*ppCtx)->mutexEncoderError)); if (pSmt->pThreadPEncCtx != NULL) { pMa->WelsFree (pSmt->pThreadPEncCtx, "pThreadPEncCtx"); pSmt->pThreadPEncCtx = NULL; } for (int i = 0; i < MAX_THREADS_NUM; i++) { if (pSmt->pThreadBsBuffer[i]) { pMa->WelsFree (pSmt->pThreadBsBuffer[i], "pSmt->pThreadBsBuffer"); pSmt->pThreadBsBuffer[i] = NULL; } } memset (&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof (bool)); pSliceB = (*ppCtx)->pSliceBs; iIdx = 0; while (pSliceB != NULL && iIdx < uiSliceNum) { pSliceB->pBsBuffer = NULL; pSliceB->uiSize = 0; pSliceB->uiBsPos = 0; ++ iIdx; ++ pSliceB; } if ((*ppCtx)->pSliceBs != NULL) { pMa->WelsFree ((*ppCtx)->pSliceBs, "pSliceBs"); (*ppCtx)->pSliceBs = NULL; } if ((*ppCtx)->pTaskManage != NULL) { delete (*ppCtx)->pTaskManage; (*ppCtx)->pTaskManage = NULL; } #ifdef MT_DEBUG // file handle for debug if (pSmt->pFSliceDiff) { fclose (pSmt->pFSliceDiff); pSmt->pFSliceDiff = NULL; } #endif//MT_DEBUG pMa->WelsFree ((*ppCtx)->pSliceThreading, "SSliceThreading"); (*ppCtx)->pSliceThreading = NULL; }