Commit f2a63e9d by claincly Committed by microkatz

Fix availableFrameCount semantic

`availableFrameCount` tracks the number of frames that is avilable on the
`SurfaceTexture`, but haven't been used (by `updateTexImage()`) yet. Thus
semantically this counter should only be decremented after calling
`updateTexImage()`, not before it.

Also reworded `getPendingFrameCount()` javadoc, "external texture" is an
internal state that is not publicised anywhere.

PiperOrigin-RevId: 488765174
parent 79cc8a59
......@@ -15,7 +15,7 @@
*/
package com.google.android.exoplayer2.effect;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
import android.graphics.SurfaceTexture;
import androidx.annotation.Nullable;
......@@ -118,7 +118,7 @@ import java.util.concurrent.atomic.AtomicInteger;
/**
* Returns the number of {@linkplain #registerInputFrame(FrameInfo) registered} frames that have
* not been rendered to the external texture yet.
* not been sent to the downstream {@link ExternalTextureProcessor} yet.
*
* <p>Can be called on any thread.
*/
......@@ -151,11 +151,11 @@ import java.util.concurrent.atomic.AtomicInteger;
return;
}
availableFrameCount.getAndDecrement();
surfaceTexture.updateTexImage();
this.currentFrame = pendingFrames.remove();
availableFrameCount.getAndDecrement();
this.currentFrame = pendingFrames.peek();
FrameInfo currentFrame = checkNotNull(this.currentFrame);
FrameInfo currentFrame = checkStateNotNull(this.currentFrame);
externalTextureProcessorInputCapacity.getAndDecrement();
surfaceTexture.getTransformMatrix(textureTransformMatrix);
externalTextureProcessor.setTextureTransformMatrix(textureTransformMatrix);
......@@ -173,6 +173,7 @@ import java.util.concurrent.atomic.AtomicInteger;
new TextureInfo(
externalTexId, /* fboId= */ C.INDEX_UNSET, currentFrame.width, currentFrame.height),
presentationTimeUs);
checkStateNotNull(pendingFrames.remove());
if (inputStreamEnded && pendingFrames.isEmpty()) {
externalTextureProcessor.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