From b0f8a8f316ff6f4e0746238286a7fe1393e0916d Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Mon, 15 May 2023 11:25:24 +0100 Subject: [PATCH] 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 857e6ebee814cb1a92875dc055dd5aff0ef07453) --- .../java/androidx/media3/effect/DefaultVideoFrameProcessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/effect/src/main/java/androidx/media3/effect/DefaultVideoFrameProcessor.java b/libraries/effect/src/main/java/androidx/media3/effect/DefaultVideoFrameProcessor.java index 228b483253..850d5b733e 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/DefaultVideoFrameProcessor.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/DefaultVideoFrameProcessor.java @@ -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) {