This works now that we've got a suitably working implementation of WelsMultipleEventsWaitSingleBlocking.
Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 2 files). Show all
Unified · Split
| @@ -2165,18 +2165,19 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 2164 unmodified lines | ||
| 2165 | 2165 | |
| 2166 | 2166 | } |
| 2167 | 2167 | #else |
| 2168 | − while (iThreadIdx < iThreadCount) { | |
| 2169 | − int res = 0; | |
| 2170 | − if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) { | |
| 2171 | − res = WelsThreadCancel ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); | |
| 2172 | − WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), WelsThreadCancel(pThreadHandles%d) return %d..\n", iThreadIdx, | |
| 2173 | − res); | |
| 2174 | − res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit | |
| 2175 | − WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), pthread_join(pThreadHandles%d) return %d..\n", iThreadIdx, | |
| 2176 | − res); | |
| 2177 | − (*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0; | |
| 2168 | + if ((*ppCtx)->pSliceThreading->pExitEncodeEvent != NULL) { | |
| 2169 | + while (iThreadIdx < iThreadCount) { | |
| 2170 | + int res = 0; | |
| 2171 | + if ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]) { | |
| 2172 | + WelsEventSignal (& (*ppCtx)->pSliceThreading->pExitEncodeEvent[iThreadIdx]); | |
| 2173 | + WelsEventSignal (& (*ppCtx)->pSliceThreading->pThreadMasterEvent[iThreadIdx]); | |
| 2174 | + res = WelsThreadJoin ((*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx]); // waiting thread exit | |
| 2175 | + WelsLog (*ppCtx, WELS_LOG_INFO, "WelsUninitEncoderExt(), pthread_join(pThreadHandles%d) return %d..\n", iThreadIdx, | |
| 2176 | + res); | |
| 2177 | + (*ppCtx)->pSliceThreading->pThreadHandles[iThreadIdx] = 0; | |
| 2178 | + } | |
| 2179 | + ++ iThreadIdx; | |
| 2178 | 2180 | } |
| 2179 | − ++ iThreadIdx; | |
| 2180 | 2181 | } |
| 2181 | 2182 | #endif//WIN32 |
| 2182 | 2183 | } |