Use pExitEncodeEvent instead of thread cancellation on unix as well

This works now that we've got a suitably working implementation
of WelsMultipleEventsWaitSingleBlocking.
This commit is contained in:
Martin Storsjö 2014-03-03 22:54:08 +02:00
parent 38a3fada24
commit baaa38737e
2 changed files with 12 additions and 13 deletions

View File

@ -2165,18 +2165,19 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) {
}
#else
while (iThreadIdx < iThreadCount) {
int res = 0;
if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) {
res = WelsThreadCancel ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]);
WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), WelsThreadCancel(pThreadHandles%d) return %d..\n", iThreadIdx,
res);
res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit
WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), pthread_join(pThreadHandles%d) return %d..\n", iThreadIdx,
res);
(*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0;
if ((*ppCtx)->pSliceThreading->pExitEncodeEvent != NULL) {
while (iThreadIdx < iThreadCount) {
int res = 0;
if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) {
WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]);
WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]);
res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit
WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), pthread_join(pThreadHandles%d) return %d..\n", iThreadIdx,
res);
(*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0;
}
++ iThreadIdx;
}
++ iThreadIdx;
}
#endif//WIN32
}

View File

@ -705,8 +705,6 @@ WELS_THREAD_ROUTINE_TYPE CodingSliceThreadProc (void* arg) {
if (NULL == pPrivateData)
WELS_THREAD_ROUTINE_RETURN (1);
WelsSetThreadCancelable();
pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx;
iThreadIdx = pPrivateData->iThreadIndex;