Misc clean-ups in ImageRenderer

Add some missing empty lines and use checkStateNotNull() everywhere.

PiperOrigin-RevId: 592173300
This commit is contained in:
christosts 2023-12-19 03:03:28 -08:00 committed by Copybara-Service
parent 087c07e596
commit 3bb233a911

View File

@ -18,7 +18,6 @@ package androidx.media3.exoplayer.image;
import static androidx.media3.common.C.FIRST_FRAME_NOT_RENDERED;
import static androidx.media3.common.C.FIRST_FRAME_NOT_RENDERED_ONLY_ALLOWED_IF_STARTED;
import static androidx.media3.common.C.FIRST_FRAME_RENDERED;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.exoplayer.source.SampleStream.FLAG_REQUIRE_FORMAT;
@ -141,7 +140,7 @@ public class ImageRenderer extends BaseRenderer {
int result = readSource(formatHolder, flagsOnlyBuffer, FLAG_REQUIRE_FORMAT);
if (result == C.RESULT_FORMAT_READ) {
// Note that this works because we only expect to enter this if-condition once per playback.
inputFormat = checkNotNull(formatHolder.format);
inputFormat = checkStateNotNull(formatHolder.format);
initDecoder();
} else if (result == C.RESULT_BUFFER_READ) {
// End of stream read having not read a format.
@ -269,7 +268,7 @@ public class ImageRenderer extends BaseRenderer {
checkStateNotNull(inputFormat);
initDecoder();
} else {
checkNotNull(outputBuffer).release();
checkStateNotNull(outputBuffer).release();
outputBuffer = null;
if (offsetQueue.isEmpty()) {
outputStreamEnded = true;
@ -334,7 +333,7 @@ public class ImageRenderer extends BaseRenderer {
if (decoderReinitializationState == REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM_THEN_WAIT) {
checkStateNotNull(inputBuffer);
inputBuffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
checkNotNull(decoder).queueInputBuffer(inputBuffer);
checkStateNotNull(decoder).queueInputBuffer(inputBuffer);
inputBuffer = null;
decoderReinitializationState = REINITIALIZATION_STATE_WAIT_END_OF_STREAM;
return false;
@ -347,12 +346,12 @@ public class ImageRenderer extends BaseRenderer {
// Input buffers with no data that are also non-EOS, only carry the timestamp for a grid
// tile. These buffers are not queued.
boolean shouldQueueBuffer =
checkNotNull(inputBuffer.data).remaining() > 0
|| checkNotNull(inputBuffer).isEndOfStream();
checkStateNotNull(inputBuffer.data).remaining() > 0
|| checkStateNotNull(inputBuffer).isEndOfStream();
if (shouldQueueBuffer) {
checkNotNull(decoder).queueInputBuffer(checkNotNull(inputBuffer));
checkStateNotNull(decoder).queueInputBuffer(checkStateNotNull(inputBuffer));
}
if (checkNotNull(inputBuffer).isEndOfStream()) {
if (checkStateNotNull(inputBuffer).isEndOfStream()) {
inputStreamEnded = true;
inputBuffer = null;
return false;
@ -362,11 +361,11 @@ public class ImageRenderer extends BaseRenderer {
if (shouldQueueBuffer) {
inputBuffer = null;
} else {
checkNotNull(inputBuffer).clear();
checkStateNotNull(inputBuffer).clear();
}
return true;
case C.RESULT_FORMAT_READ:
inputFormat = checkNotNull(formatHolder.format);
inputFormat = checkStateNotNull(formatHolder.format);
decoderReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM_THEN_WAIT;
return true;
default: