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:
parent
7bbf72c202
commit
b8c1e22389
@ -65,30 +65,21 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
private final float[] textureTransformMatrix;
|
private final float[] textureTransformMatrix;
|
||||||
private final Queue<FrameInfo> pendingFrames;
|
private final Queue<FrameInfo> pendingFrames;
|
||||||
private final ScheduledExecutorService forceEndOfStreamExecutorService;
|
private final ScheduledExecutorService forceEndOfStreamExecutorService;
|
||||||
|
|
||||||
// Created on any thread. Otherwise, read and written on the GL thread only.
|
|
||||||
private final AtomicInteger externalShaderProgramInputCapacity;
|
private final AtomicInteger externalShaderProgramInputCapacity;
|
||||||
|
|
||||||
// Counts the frames that are registered before flush but are made available after flush.
|
// 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;
|
private int numberOfFramesToDropOnBecomingAvailable;
|
||||||
|
|
||||||
// Read and written on the GL thread only.
|
|
||||||
private int availableFrameCount;
|
private int availableFrameCount;
|
||||||
|
|
||||||
// Read and written on the GL thread only.
|
|
||||||
private boolean currentInputStreamEnded;
|
private boolean currentInputStreamEnded;
|
||||||
|
|
||||||
// The frame that is sent downstream and is not done processing yet.
|
// 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 FrameInfo currentFrame;
|
||||||
|
|
||||||
@Nullable private Future<?> forceSignalEndOfStreamFuture;
|
@Nullable private Future<?> forceSignalEndOfStreamFuture;
|
||||||
|
|
||||||
// Whether to reject frames from the SurfaceTexture. Accessed on the GL thread only.
|
|
||||||
private boolean shouldRejectIncomingFrames;
|
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 glObjectsProvider The {@link GlObjectsProvider} for using EGL and GLES.
|
||||||
* @param externalShaderProgram The {@link ExternalShaderProgram} for which this {@code
|
* @param externalShaderProgram The {@link ExternalShaderProgram} for which this {@code
|
||||||
@ -227,8 +218,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||||||
forceEndOfStreamExecutorService.shutdownNow();
|
forceEndOfStreamExecutorService.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods that must be called on the GL thread.
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void flush() {
|
protected void flush() {
|
||||||
// A frame that is registered before flush may arrive after flush.
|
// A frame that is registered before flush may arrive after flush.
|
||||||
|
@ -152,8 +152,7 @@ import androidx.media3.common.util.TimestampIterator;
|
|||||||
*/
|
*/
|
||||||
public abstract void release() throws VideoFrameProcessingException;
|
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() {
|
protected void flush() {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
if (onFlushCompleteTask != null) {
|
if (onFlushCompleteTask != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user