This avoids using a separate event just for signalling that a thread has finished running.
Showing the changes to codec/encoder/core/src/slice_multi_threading.cpp (1 of 3 files). Show all
Unified · Split
| @@ -362,11 +362,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara · 361 unmodified lines | |||
| 362 | pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx; | 362 | pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx; |
| 363 | pSmt->pThreadHandles[iIdx] = 0; | 363 | pSmt->pThreadHandles[iIdx] = 0; |
| 364 | 364 | ||
| 365 | #ifdef _WIN32 | ||
| 366 | WelsSnprintf (name, SEM_NAME_MAX, "fs%d%s", iIdx, pSmt->eventNamespace); | ||
| 367 | err = WelsEventOpen (&pSmt->pFinSliceCodingEvent[iIdx], name); | ||
| 368 | MT_TRACE_LOG ((*ppCtx), WELS_LOG_INFO, "[MT] Open pFinSliceCodingEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); | ||
| 369 | #endif//_WIN32 | ||
| 370 | WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); | 365 | WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); |
| 371 | err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name); | 366 | err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name); |
| 372 | MT_TRACE_LOG ((*ppCtx), WELS_LOG_INFO, "[MT] Open pExitEncodeEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); | 367 | MT_TRACE_LOG ((*ppCtx), WELS_LOG_INFO, "[MT] Open pExitEncodeEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno); |
| @@ -460,8 +455,6 @@ void ReleaseMtResource (sWelsEncCtx** ppCtx) { · 87 unmodified lines | |||
| 460 | if (pSmt->pThreadHandles != NULL && pSmt->pThreadHandles[iIdx] != NULL) | 455 | if (pSmt->pThreadHandles != NULL && pSmt->pThreadHandles[iIdx] != NULL) |
| 461 | WelsThreadDestroy (&pSmt->pThreadHandles[iIdx]); | 456 | WelsThreadDestroy (&pSmt->pThreadHandles[iIdx]); |
| 462 | 457 | ||
| 463 | WelsSnprintf (ename, SEM_NAME_MAX, "fs%d%s", iIdx, pSmt->eventNamespace); | ||
| 464 | WelsEventClose (&pSmt->pFinSliceCodingEvent[iIdx], ename); | ||
| 465 | #endif//_WIN32 | 458 | #endif//_WIN32 |
| 466 | WelsSnprintf (ename, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); | 459 | WelsSnprintf (ename, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace); |
| 467 | WelsEventClose (&pSmt->pExitEncodeEvent[iIdx], ename); | 460 | WelsEventClose (&pSmt->pExitEncodeEvent[iIdx], ename); |
| @@ -957,10 +950,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) { · 489 unmodified lines | |||
| 957 | } | 950 | } |
| 958 | } while (1); | 951 | } while (1); |
| 959 | 952 | ||
| 960 | #ifdef _WIN32 | ||
| 961 | WelsEventSignal (&pEncPEncCtx->pSliceThreading->pFinSliceCodingEvent[iEventIdx]); // notify to mother encoding threading | ||
| 962 | #endif//WIN32 | ||
| 963 | |||
| 964 | //sync multi-threading error | 953 | //sync multi-threading error |
| 965 | WelsMutexLock (&pEncPEncCtx->mutexEncoderError); | 954 | WelsMutexLock (&pEncPEncCtx->mutexEncoderError); |
| 966 | if (uiThrdRet) pEncPEncCtx->iEncoderError |= uiThrdRet; | 955 | if (uiThrdRet) pEncPEncCtx->iEncoderError |= uiThrdRet; |