From 353523bb0721f2144811a7ee0fb4791198f02d0d Mon Sep 17 00:00:00 2001 From: claincly Date: Thu, 20 Apr 2023 22:26:43 +0100 Subject: [PATCH] Simplify end of stream signaling again Whenever a frame is queued to the shader, it's guaranteed that there will be a subsequent `onInputFrameProcessed` callback, so we can pass on the end-of-stream signal there. PiperOrigin-RevId: 525850141 --- .../media3/effect/ExternalTextureManager.java | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java b/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java index d4f454658c..b99eb2ea20 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java @@ -57,11 +57,6 @@ import java.util.concurrent.atomic.AtomicInteger; // Read and written on the GL thread only. private boolean inputStreamEnded; - // TODO(b/278273122): Remove this flag and the signal end of input call after queueing a frame if - // all frames notify that they've been processed. - - // Read and written on the GL thread only. - private boolean hasSignaledEndOfInput; // The frame that is sent downstream and is not done processing yet. // Set to null on any thread. Read and set to non-null on the GL thread only. @Nullable private volatile FrameInfo currentFrame; @@ -135,7 +130,7 @@ import java.util.concurrent.atomic.AtomicInteger; () -> { currentFrame = null; if (inputStreamEnded && pendingFrames.isEmpty()) { - maybeSignalEndOfInput(); + externalShaderProgram.signalEndOfCurrentInputStream(); } else { maybeQueueFrameToExternalShaderProgram(); } @@ -183,7 +178,7 @@ import java.util.concurrent.atomic.AtomicInteger; () -> { inputStreamEnded = true; if (pendingFrames.isEmpty() && currentFrame == null) { - maybeSignalEndOfInput(); + externalShaderProgram.signalEndOfCurrentInputStream(); } }); } @@ -248,16 +243,6 @@ import java.util.concurrent.atomic.AtomicInteger; currentFrame.height), presentationTimeUs); checkStateNotNull(pendingFrames.remove()); - - if (inputStreamEnded && pendingFrames.isEmpty()) { - maybeSignalEndOfInput(); - } - } - - private void maybeSignalEndOfInput() { - if (!hasSignaledEndOfInput) { - hasSignaledEndOfInput = true; - externalShaderProgram.signalEndOfCurrentInputStream(); - } + // If the queued frame is the last frame, end of stream will be signaled onInputFrameProcessed. } }