Effect: Use element instead of peek, when throwing if null.

If nullness should result in an exception, we should throw as soon as possible,
so that stack traces are easier to follow.

Did a quick scan of media3.effect+transformer and this covers all uses of
peek that immediately throw there.

PiperOrigin-RevId: 603393366
(cherry picked from commit dd7846ee1cbeb48ddb5495858a71517858df0554)
This commit is contained in:
huangdarwin 2024-02-01 09:27:37 -08:00 committed by SheenaChhabra
parent bfa492bf4f
commit ecaff24e46
2 changed files with 2 additions and 2 deletions

View File

@ -158,7 +158,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
return;
}
BitmapFrameSequenceInfo currentBitmapInfo = checkNotNull(pendingBitmaps.peek());
BitmapFrameSequenceInfo currentBitmapInfo = pendingBitmaps.element();
FrameInfo currentFrameInfo = currentBitmapInfo.frameInfo;
TimestampIterator inStreamOffsetsUs = currentBitmapInfo.inStreamOffsetsUs;
checkState(currentBitmapInfo.inStreamOffsetsUs.hasNext());

View File

@ -299,7 +299,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
surfaceTexture.updateTexImage();
availableFrameCount--;
this.currentFrame = pendingFrames.peek();
this.currentFrame = pendingFrames.element();
FrameInfo currentFrame = checkStateNotNull(this.currentFrame);
externalShaderProgramInputCapacity.decrementAndGet();