There is no point in doing a timed wait here - there's no work that we can do if the wait timed out, and sleeping for 1 ms inbetween doesn't help, it only adds potential extra latency to reacting to threads that need more work to do.
Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 1 file). Show all
Unified · Split
| @@ -3280,7 +3280,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 3279 unmodified lines | ||
| 3280 | 3280 | |
| 3281 | 3281 | lwait = WelsMultipleEventsWaitSingleBlocking (iNumThreadsScheduled, |
| 3282 | 3282 | &pCtx->pSliceThreading->pSliceCodedEvent[0], |
| 3283 | − 2); // 2 ms for one tick | |
| 3283 | + (uint32_t) -1); | |
| 3284 | 3284 | iEventId = (int32_t) (lwait - WELS_THREAD_ERROR_WAIT_OBJECT_0); |
| 3285 | 3285 | if (iEventId >= 0 && iEventId < iNumThreadsScheduled) { |
| 3286 | 3286 | if (iIndexOfSliceToBeCoded < iSliceCount) { |
| @@ -3293,8 +3293,6 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 6 unmodified lines | ||
| 3293 | 3293 | } else { // no other slices left for coding |
| 3294 | 3294 | -- iNumThreadsRunning; |
| 3295 | 3295 | } |
| 3296 | − } else { | |
| 3297 | − WelsSleep (1); | |
| 3298 | 3296 | } |
| 3299 | 3297 | #else |
| 3300 | 3298 | // TODO for pthread platforms |