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