mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
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
This commit is contained in:
parent
acbd340e84
commit
353523bb07
@ -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.
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user