changeset 9610:e212eee15e98

frameencoder: use a timed wait to avoid a help-wanted flag race hazard I've seen one deadlock when running within a debugger that pointed to a frame encoder becoming stuck waiting for completion but no worker threads were aware that the frame needed work.
author Steve Borho <steve@borho.org>
date Wed, 04 Mar 2015 08:30:49 -0600
parents 1ce139389b3b
children 7605e562bef6
files source/encoder/frameencoder.cpp
diffstat 1 files changed, 3 insertions(+-), 1 deletions(-) [+]
line wrap: on
line diff
--- a/source/encoder/frameencoder.cpp	Mon Mar 02 19:54:42 2015 -0600
+++ b/source/encoder/frameencoder.cpp	Wed Mar 04 08:30:49 2015 -0600
@@ -709,7 +709,9 @@ void FrameEncoder::compressCTURows()
 
         m_allRowsAvailableTime = x265_mdate();
         tryWakeOne(); /* ensure one thread is active or help-wanted flag is set prior to blocking */
-        m_completionEvent.wait();
+        static const int block_ms = 250;
+        while (m_completionEvent.timedWait(block_ms))
+            tryWakeOne();
     }
     else
     {