Clarify threading-related comments in texture manager

In `ExternalTextureManager` fields are accessed from the GL thread and the class needs to be constructed on the GL thread.

Also visibly document threading requirement in the parent class.

PiperOrigin-RevId: 585941284
This commit is contained in:
andrewlewis 2023-11-28 05:27:45 -08:00 committed by Copybara-Service
parent 7bbf72c202
commit b8c1e22389
2 changed files with 3 additions and 15 deletions

View File

@ -65,30 +65,21 @@ import java.util.concurrent.atomic.AtomicInteger;
private final float[] textureTransformMatrix;
private final Queue<FrameInfo> pendingFrames;
private final ScheduledExecutorService forceEndOfStreamExecutorService;
// Created on any thread. Otherwise, read and written on the GL thread only.
private final AtomicInteger externalShaderProgramInputCapacity;
// Counts the frames that are registered before flush but are made available after flush.
// Read and written on the GL thread only.
private int numberOfFramesToDropOnBecomingAvailable;
// Read and written on the GL thread only.
private int availableFrameCount;
// Read and written on the GL thread only.
private boolean currentInputStreamEnded;
// The frame that is sent downstream and is not done processing yet.
// Read and written on the GL thread only.
@Nullable private FrameInfo currentFrame;
@Nullable private Future<?> forceSignalEndOfStreamFuture;
// Whether to reject frames from the SurfaceTexture. Accessed on the GL thread only.
private boolean shouldRejectIncomingFrames;
/**
* Creates a new instance.
* Creates a new instance. The caller's thread must have a current GL context.
*
* @param glObjectsProvider The {@link GlObjectsProvider} for using EGL and GLES.
* @param externalShaderProgram The {@link ExternalShaderProgram} for which this {@code
@ -227,8 +218,6 @@ import java.util.concurrent.atomic.AtomicInteger;
forceEndOfStreamExecutorService.shutdownNow();
}
// Methods that must be called on the GL thread.
@Override
protected void flush() {
// A frame that is registered before flush may arrive after flush.

View File

@ -152,8 +152,7 @@ import androidx.media3.common.util.TimestampIterator;
*/
public abstract void release() throws VideoFrameProcessingException;
// Methods that must be called on the GL thread.
/** Clears any pending data. Must be called on the GL thread. */
protected void flush() {
synchronized (lock) {
if (onFlushCompleteTask != null) {