ref: baaa38737e5e4ac27f7de4835dbc0753ff955c74
parent: 38a3fada2456ab8480731f85fbeb01e01c6cb575
author: Martin Storsjö <[email protected]>
date: Mon Mar 3 17:54:08 EST 2014
Use pExitEncodeEvent instead of thread cancellation on unix as well This works now that we've got a suitably working implementation of WelsMultipleEventsWaitSingleBlocking.
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -2165,18 +2165,19 @@
}
#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
}
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -705,8 +705,6 @@
if (NULL == pPrivateData)
WELS_THREAD_ROUTINE_RETURN (1);
- WelsSetThreadCancelable();
-
pEncPEncCtx = (sWelsEncCtx*)pPrivateData->pWelsPEncCtx;
iThreadIdx = pPrivateData->iThreadIndex;