Commit 0f4fcc11 by claincly Committed by christosts

Report flushing completed after all pending frames are decoded.

With the current ExtTexMgr,

it can happen that

- `x` frames are registered, but haven't arrived yet
- flush
  - need to drop `x` frames when they arrive on SurfaceTexture
  - status is reset to 0 pending, 0 available, drop `x` when frames arrive
- register one frame
  - status is set to 1 pending, 0 available, drop `x` when frames arrive
- flush
  - now the number of frame to drop is reset to `pending - available = 1`
  - but it should be `x+1`

This CL solves the issue by reporting (by running the afterFlushTask) flush completes only after all the pending frames before calling flush are accounted for.

PiperOrigin-RevId: 506310671
parent 656a1d94
...@@ -58,6 +58,7 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -58,6 +58,7 @@ import java.util.concurrent.atomic.AtomicInteger;
// 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;
// TODO(b/238302341) Remove the use of after flush task, block the calling thread instead.
@Nullable private volatile FrameProcessingTask onFlushCompleteTask; @Nullable private volatile FrameProcessingTask onFlushCompleteTask;
private long previousStreamOffsetUs; private long previousStreamOffsetUs;
...@@ -97,6 +98,7 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -97,6 +98,7 @@ import java.util.concurrent.atomic.AtomicInteger;
if (numberOfFramesToDropOnBecomingAvailable > 0) { if (numberOfFramesToDropOnBecomingAvailable > 0) {
numberOfFramesToDropOnBecomingAvailable--; numberOfFramesToDropOnBecomingAvailable--;
surfaceTexture.updateTexImage(); surfaceTexture.updateTexImage();
maybeExecuteAfterFlushTask();
} else { } else {
availableFrameCount++; availableFrameCount++;
maybeQueueFrameToExternalTextureProcessor(); maybeQueueFrameToExternalTextureProcessor();
...@@ -184,10 +186,14 @@ import java.util.concurrent.atomic.AtomicInteger; ...@@ -184,10 +186,14 @@ import java.util.concurrent.atomic.AtomicInteger;
externalTextureProcessorInputCapacity.set(0); externalTextureProcessorInputCapacity.set(0);
currentFrame = null; currentFrame = null;
pendingFrames.clear(); pendingFrames.clear();
maybeExecuteAfterFlushTask();
}
if (onFlushCompleteTask != null) { private void maybeExecuteAfterFlushTask() {
frameProcessingTaskExecutor.submitWithHighPriority(onFlushCompleteTask); if (onFlushCompleteTask == null || numberOfFramesToDropOnBecomingAvailable > 0) {
return;
} }
frameProcessingTaskExecutor.submitWithHighPriority(onFlushCompleteTask);
} }
@WorkerThread @WorkerThread
......
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