History

put CWelsThreadPool to singleTon for future usage (including add sink for IWelsTask)

sijchen committed 10 years ago

Commit d4f09d91 parent 52d25f510 files · +273 −85Browse files

Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 10 files). Show all

Unified · Split

codec/encoder/core/src/slice_multi_threading.cpp+12−3
@@ -333,9 +333,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 332 unmodified lines
333 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pReadySliceCodingEvent%d = 0x%p named(%s) ret%d err%d", iIdx,333 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pReadySliceCodingEvent%d = 0x%p named(%s) ret%d err%d", iIdx,
334 (void*)pSmt->pReadySliceCodingEvent[iIdx], name, err, errno);334 (void*)pSmt->pReadySliceCodingEvent[iIdx], name, err, errno);
335 335
336 pSmt->pThreadBsBuffer[iIdx] = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pSmt->pThreadBsBuffer");
337 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadBsBuffer[iIdx]), FreeMemorySvc (ppCtx))
338
339 pSmt->pSliceInThread[iIdx] = (SSlice*)pMa->WelsMalloc (sizeof (SSlice)*iMaxSliceNumInThread, "pSmt->pSliceInThread");336 pSmt->pSliceInThread[iIdx] = (SSlice*)pMa->WelsMalloc (sizeof (SSlice)*iMaxSliceNumInThread, "pSmt->pSliceInThread");
340 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceInThread[iIdx]), FreeMemorySvc (ppCtx))337 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pSliceInThread[iIdx]), FreeMemorySvc (ppCtx))
341 338
@@ -350,6 +347,7 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 8 unmodified lines
350 pSmt->piSliceIndexInThread[iIdx] = NULL;347 pSmt->piSliceIndexInThread[iIdx] = NULL;
351 }348 }
352 349
350
353 WelsSnprintf (name, SEM_NAME_MAX, "scm%s", pSmt->eventNamespace);351 WelsSnprintf (name, SEM_NAME_MAX, "scm%s", pSmt->eventNamespace);
354 err = WelsEventOpen (&pSmt->pSliceCodedMasterEvent, name);352 err = WelsEventOpen (&pSmt->pSliceCodedMasterEvent, name);
355 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedMasterEvent named(%s) ret%d err%d", name, err, errno);353 MT_TRACE_LOG (pLogCtx, WELS_LOG_INFO, "[MT] Open pSliceCodedMasterEvent named(%s) ret%d err%d", name, err, errno);
@@ -360,6 +358,17 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 4 unmodified lines
360 (*ppCtx)->pTaskManage = IWelsTaskManage::CreateTaskManage (*ppCtx, iNumSpatialLayers, bDynamicSlice);358 (*ppCtx)->pTaskManage = IWelsTaskManage::CreateTaskManage (*ppCtx, iNumSpatialLayers, bDynamicSlice);
361 WELS_VERIFY_RETURN_PROC_IF (iReturn, (NULL == (*ppCtx)->pTaskManage), FreeMemorySvc (ppCtx))359 WELS_VERIFY_RETURN_PROC_IF (iReturn, (NULL == (*ppCtx)->pTaskManage), FreeMemorySvc (ppCtx))
362 360
361 int32_t iThreadBufferNum = WELS_MIN((*ppCtx)->pTaskManage->GetThreadPoolThreadNum(), MAX_THREADS_NUM);
362 for (iIdx = 0;iIdx < iThreadBufferNum; iIdx++) {
363 pSmt->pThreadBsBuffer[iIdx] = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pSmt->pThreadBsBuffer");
364 WELS_VERIFY_RETURN_PROC_IF (1, (NULL == pSmt->pThreadBsBuffer[iIdx]), FreeMemorySvc (ppCtx))
365 }
366 if (iThreadBufferNum < MAX_THREADS_NUM) {
367 for (iIdx = iThreadBufferNum; iIdx < MAX_THREADS_NUM; iIdx++) {
368 pSmt->pThreadBsBuffer[iIdx] = NULL;
369 }
370 }
371
363 memset (&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof (bool));372 memset (&pSmt->bThreadBsBufferUsage, 0, MAX_THREADS_NUM * sizeof (bool));
364 iReturn = WelsMutexInit (&pSmt->mutexThreadBsBufferUsage);373 iReturn = WelsMutexInit (&pSmt->mutexThreadBsBufferUsage);
365 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))374 WELS_VERIFY_RETURN_PROC_IF (1, (WELS_THREAD_ERROR_OK != iReturn), FreeMemorySvc (ppCtx))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t