Make sure exceptions are re-thrown even if they occur when the queue is full.
authorCarl Hetherington <cth@carlh.net>
Sun, 21 Nov 2021 22:35:56 +0000 (23:35 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 24 Nov 2021 23:55:02 +0000 (00:55 +0100)
src/lib/j2k_encoder.cc

index 70f3c32d4983e96573ebabc8f1ebbe77c34acd7a..27eeaa48366e78fc57dd0ead88b0a31d29173275 100644 (file)
@@ -218,13 +218,16 @@ J2KEncoder::encode (shared_ptr<PlayerVideo> pv, DCPTime time)
                LOG_TIMING ("decoder-sleep queue=%1 threads=%2", _queue.size(), threads);
                _full_condition.wait (queue_lock);
                LOG_TIMING ("decoder-wake queue=%1 threads=%2", _queue.size(), threads);
+               _writer->rethrow ();
+               /* Re-throw any exception raised by one of our threads.  If more
+                  than one has thrown an exception, only one will be rethrown, I think;
+                  but then, if that happens something has gone badly wrong.
+               */
+               rethrow ();
        }
 
+       /* Do it again in case an exception was thrown with an emptier queue */
        _writer->rethrow ();
-       /* Re-throw any exception raised by one of our threads.  If more
-          than one has thrown an exception, only one will be rethrown, I think;
-          but then, if that happens something has gone badly wrong.
-       */
        rethrow ();
 
        auto const position = time.frames_floor(_film->video_frame_rate());