Commit 69187523 by krocard Committed by Oliver Woodman

Renaming to make pasthrough modes more explicit

Passthrough mode can use a codec or not, but
the code only mentioned "passthrough" in most cases,
making the specific mode confusing.

For example both `MediaCodecRenderer` and
it's derived class `MediaCodecAudioRenderer`
had a private `passthroughEnabled` field,
but they were used for the opposite modes!

This change renames all relevant variables/functions
to explicit `CodecPassthrough` or `Bypass`.

PiperOrigin-RevId: 319225235
parent ab348c04
......@@ -84,10 +84,9 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
private final AudioSink audioSink;
private int codecMaxInputSize;
private boolean passthroughEnabled;
private boolean codecNeedsDiscardChannelsWorkaround;
private boolean codecNeedsEosBufferTimestampWorkaround;
@Nullable private Format passthroughCodecFormat;
@Nullable private Format codecPassthroughFormat;
@Nullable private Format inputFormat;
private long currentPositionUs;
private boolean allowFirstBufferPositionDiscontinuity;
......@@ -299,14 +298,14 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
codecMaxInputSize = getCodecMaxInputSize(codecInfo, format, getStreamFormats());
codecNeedsDiscardChannelsWorkaround = codecNeedsDiscardChannelsWorkaround(codecInfo.name);
codecNeedsEosBufferTimestampWorkaround = codecNeedsEosBufferTimestampWorkaround(codecInfo.name);
passthroughEnabled =
MimeTypes.AUDIO_RAW.equals(codecInfo.mimeType)
&& !MimeTypes.AUDIO_RAW.equals(format.sampleMimeType);
MediaFormat mediaFormat =
getMediaFormat(format, codecInfo.codecMimeType, codecMaxInputSize, codecOperatingRate);
codecAdapter.configure(mediaFormat, /* surface= */ null, crypto, /* flags= */ 0);
// Store the input MIME type if we're using the passthrough codec.
passthroughCodecFormat = passthroughEnabled ? format : null;
boolean codecPassthroughEnabled =
MimeTypes.AUDIO_RAW.equals(codecInfo.mimeType)
&& !MimeTypes.AUDIO_RAW.equals(format.sampleMimeType);
codecPassthroughFormat = codecPassthroughEnabled ? format : null;
}
@Override
......@@ -388,8 +387,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
@Override
protected void configureOutput(Format outputFormat) throws ExoPlaybackException {
Format audioSinkInputFormat;
if (passthroughCodecFormat != null) {
@C.Encoding int passthroughEncoding = getPassthroughEncoding(passthroughCodecFormat);
if (codecPassthroughFormat != null) {
@C.Encoding int passthroughEncoding = getPassthroughEncoding(codecPassthroughFormat);
// TODO(b/112299307): Passthrough can have become unavailable since usePassthrough was called.
Assertions.checkState(passthroughEncoding != C.ENCODING_INVALID);
audioSinkInputFormat = outputFormat.buildUpon().setEncoding(passthroughEncoding).build();
......@@ -426,7 +425,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
}
@Override
protected void onOutputPassthroughFormatChanged(Format outputFormat) throws ExoPlaybackException {
protected void onOutputBypassFormatChanged(Format outputFormat) throws ExoPlaybackException {
@C.Encoding int passthroughEncoding = getPassthroughEncoding(outputFormat);
// TODO(b/112299307): Passthrough can have become unavailable since usePassthrough was called.
Assertions.checkState(passthroughEncoding != C.ENCODING_INVALID);
......@@ -631,7 +630,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
bufferPresentationTimeUs = getLargestQueuedPresentationTimeUs();
}
if (passthroughEnabled && (bufferFlags & MediaCodec.BUFFER_FLAG_CODEC_CONFIG) != 0) {
if (codecPassthroughFormat != null
&& (bufferFlags & MediaCodec.BUFFER_FLAG_CODEC_CONFIG) != 0) {
// Discard output buffers from the passthrough (raw) decoder containing codec specific data.
codec.releaseOutputBuffer(bufferIndex, false);
return true;
......
......@@ -515,7 +515,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
setOutputSurfaceV23(codec, surface);
} else {
releaseCodec();
maybeInitCodecOrPassthrough();
maybeInitCodecOrBypass();
}
}
if (surface != null && surface != dummySurface) {
......
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