Commit 353523bb by claincly Committed by Rohit Singh

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
parent acbd340e
...@@ -57,11 +57,6 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -57,11 +57,6 @@ import java.util.concurrent.atomic.AtomicInteger;
// Read and written on the GL thread only. // Read and written on the GL thread only.
private boolean inputStreamEnded; 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. // 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. // Set to null on any thread. Read and set to non-null on the GL thread only.
@Nullable private volatile FrameInfo currentFrame; @Nullable private volatile FrameInfo currentFrame;
...@@ -135,7 +130,7 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -135,7 +130,7 @@ import java.util.concurrent.atomic.AtomicInteger;
() -> { () -> {
currentFrame = null; currentFrame = null;
if (inputStreamEnded && pendingFrames.isEmpty()) { if (inputStreamEnded && pendingFrames.isEmpty()) {
maybeSignalEndOfInput(); externalShaderProgram.signalEndOfCurrentInputStream();
} else { } else {
maybeQueueFrameToExternalShaderProgram(); maybeQueueFrameToExternalShaderProgram();
} }
...@@ -183,7 +178,7 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -183,7 +178,7 @@ import java.util.concurrent.atomic.AtomicInteger;
() -> { () -> {
inputStreamEnded = true; inputStreamEnded = true;
if (pendingFrames.isEmpty() && currentFrame == null) { if (pendingFrames.isEmpty() && currentFrame == null) {
maybeSignalEndOfInput(); externalShaderProgram.signalEndOfCurrentInputStream();
} }
}); });
} }
...@@ -248,16 +243,6 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -248,16 +243,6 @@ import java.util.concurrent.atomic.AtomicInteger;
currentFrame.height), currentFrame.height),
presentationTimeUs); presentationTimeUs);
checkStateNotNull(pendingFrames.remove()); checkStateNotNull(pendingFrames.remove());
// If the queued frame is the last frame, end of stream will be signaled onInputFrameProcessed.
if (inputStreamEnded && pendingFrames.isEmpty()) {
maybeSignalEndOfInput();
}
}
private void maybeSignalEndOfInput() {
if (!hasSignaledEndOfInput) {
hasSignaledEndOfInput = true;
externalShaderProgram.signalEndOfCurrentInputStream();
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment