Signal end-of-stream after creating latch

The output end-of-stream notification from the last shader could theoretically
arrive before the latch for detecting it is created, which might cause waiting
on the latch indefinitely. Create the latch before signaling end of stream so
that it's guaranteed to be set before the end-of-stream signal arrives.

PiperOrigin-RevId: 532056472
(cherry picked from commit 857e6ebee8)
This commit is contained in:
andrewlewis 2023-05-15 11:25:24 +01:00 committed by Tofunmi Adigun-Hameed
parent 7e30091196
commit b0f8a8f316

View file

@ -374,9 +374,9 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
}
}
checkNotNull(textureManager).signalEndOfCurrentInputStream();
// Wait until the current input stream is processed before continuing to the next input.
latch = new CountDownLatch(1);
checkNotNull(textureManager).signalEndOfCurrentInputStream();
try {
latch.await();
} catch (InterruptedException e) {