Use WelsThreadJoin on windows as well

This avoids using a separate event just for signalling that
a thread has finished running.
This commit is contained in:
Martin Storsjö 2014-03-03 22:57:57 +02:00
parent 181fe0a99e
commit b4aa9be7de
3 changed files with 1 additions and 16 deletions

View File

@ -100,9 +100,6 @@ WELS_EVENT pUpdateMbListEvent[MAX_THREADS_NUM]; // signal to update mb list
WELS_EVENT pFinUpdateMbListEvent[MAX_THREADS_NUM]; // signal to indicate finish updating mb list
WELS_EVENT pExitEncodeEvent[MAX_THREADS_NUM]; // event for exit encoding event
WELS_EVENT pThreadMasterEvent[MAX_THREADS_NUM]; // event for indicating that some event has been signalled to the thread
#ifdef _WIN32
WELS_EVENT pFinSliceCodingEvent[MAX_THREADS_NUM]; // notify slice coding thread is done
#endif//_WIN32
WELS_MUTEX mutexSliceNumUpdate; // for dynamic slicing mode MT

View File

@ -2158,11 +2158,10 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] != NULL) // iThreadIdx is already created successfully
WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]);
WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit
++ iThreadIdx;
} while (iThreadIdx < iThreadCount);
WelsMultipleEventsWaitAllBlocking (iThreadCount, & (*ppCtx)->pSliceThreading->pFinSliceCodingEvent[0]);
}
#else
if ((*ppCtx)->pSliceThreading->pExitEncodeEvent != NULL) {

View File

@ -362,11 +362,6 @@ int32_t RequestMtResource (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPara
pSmt->pThreadPEncCtx[iIdx].iThreadIndex = iIdx;
pSmt->pThreadHandles[iIdx] = 0;
#ifdef _WIN32
WelsSnprintf (name, SEM_NAME_MAX, "fs%d%s", iIdx, pSmt->eventNamespace);
err = WelsEventOpen (&pSmt->pFinSliceCodingEvent[iIdx], name);
MT_TRACE_LOG ((*ppCtx), WELS_LOG_INFO, "[MT] Open pFinSliceCodingEvent%d named(%s) ret%d err%d\n", iIdx, name, err, errno);
#endif//_WIN32
WelsSnprintf (name, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace);
err = WelsEventOpen (&pSmt->pExitEncodeEvent[iIdx], name);
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) {
if (pSmt->pThreadHandles != NULL && pSmt->pThreadHandles[iIdx] != NULL)
WelsThreadDestroy (&pSmt->pThreadHandles[iIdx]);
WelsSnprintf (ename, SEM_NAME_MAX, "fs%d%s", iIdx, pSmt->eventNamespace);
WelsEventClose (&pSmt->pFinSliceCodingEvent[iIdx], ename);
#endif//_WIN32
WelsSnprintf (ename, SEM_NAME_MAX, "ee%d%s", iIdx, pSmt->eventNamespace);
WelsEventClose (&pSmt->pExitEncodeEvent[iIdx], ename);
@ -957,10 +950,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
}
} while (1);
#ifdef _WIN32
WelsEventSignal (&pEncPEncCtx->pSliceThreading->pFinSliceCodingEvent[iEventIdx]); // notify to mother encoding threading
#endif//WIN32
//sync multi-threading error
WelsMutexLock (&pEncPEncCtx->mutexEncoderError);
if (uiThrdRet) pEncPEncCtx->iEncoderError |= uiThrdRet;