Add nullness annotations to MediaCodeAudioRenderer

#fixit

PiperOrigin-RevId: 559175846
This commit is contained in:
rohks 2023-08-22 19:36:58 +01:00 committed by Ian Baker
parent ff39726368
commit bfa32b3998

View File

@ -409,8 +409,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
boolean requiresSecureDecoder, boolean requiresSecureDecoder,
AudioSink audioSink) AudioSink audioSink)
throws DecoderQueryException { throws DecoderQueryException {
@Nullable String mimeType = format.sampleMimeType; if (format.sampleMimeType == null) {
if (mimeType == null) {
return ImmutableList.of(); return ImmutableList.of();
} }
if (audioSink.supportsFormat(format)) { if (audioSink.supportsFormat(format)) {
@ -526,7 +525,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
@Nullable @Nullable
protected DecoderReuseEvaluation onInputFormatChanged(FormatHolder formatHolder) protected DecoderReuseEvaluation onInputFormatChanged(FormatHolder formatHolder)
throws ExoPlaybackException { throws ExoPlaybackException {
inputFormat = checkNotNull(formatHolder.format); Format inputFormat = checkNotNull(formatHolder.format);
this.inputFormat = inputFormat;
@Nullable DecoderReuseEvaluation evaluation = super.onInputFormatChanged(formatHolder); @Nullable DecoderReuseEvaluation evaluation = super.onInputFormatChanged(formatHolder);
eventDispatcher.inputFormatChanged(inputFormat, evaluation); eventDispatcher.inputFormatChanged(inputFormat, evaluation);
return evaluation; return evaluation;
@ -542,6 +542,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
} else if (getCodec() == null) { // Direct playback with codec bypass. } else if (getCodec() == null) { // Direct playback with codec bypass.
audioSinkInputFormat = format; audioSinkInputFormat = format;
} else { } else {
checkNotNull(mediaFormat);
@C.PcmEncoding int pcmEncoding; @C.PcmEncoding int pcmEncoding;
if (MimeTypes.AUDIO_RAW.equals(format.sampleMimeType)) { if (MimeTypes.AUDIO_RAW.equals(format.sampleMimeType)) {
// For PCM streams, the encoder passes through int samples despite set to float mode. // For PCM streams, the encoder passes through int samples despite set to float mode.
@ -778,15 +779,15 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
throws ExoPlaybackException { throws ExoPlaybackException {
switch (messageType) { switch (messageType) {
case MSG_SET_VOLUME: case MSG_SET_VOLUME:
audioSink.setVolume((Float) message); audioSink.setVolume((Float) checkNotNull(message));
break; break;
case MSG_SET_AUDIO_ATTRIBUTES: case MSG_SET_AUDIO_ATTRIBUTES:
AudioAttributes audioAttributes = (AudioAttributes) message; AudioAttributes audioAttributes = (AudioAttributes) message;
audioSink.setAudioAttributes(audioAttributes); audioSink.setAudioAttributes(checkNotNull(audioAttributes));
break; break;
case MSG_SET_AUX_EFFECT_INFO: case MSG_SET_AUX_EFFECT_INFO:
AuxEffectInfo auxEffectInfo = (AuxEffectInfo) message; AuxEffectInfo auxEffectInfo = (AuxEffectInfo) message;
audioSink.setAuxEffectInfo(auxEffectInfo); audioSink.setAuxEffectInfo(checkNotNull(auxEffectInfo));
break; break;
case MSG_SET_PREFERRED_AUDIO_DEVICE: case MSG_SET_PREFERRED_AUDIO_DEVICE:
if (Util.SDK_INT >= 23) { if (Util.SDK_INT >= 23) {
@ -794,10 +795,10 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
} }
break; break;
case MSG_SET_SKIP_SILENCE_ENABLED: case MSG_SET_SKIP_SILENCE_ENABLED:
audioSink.setSkipSilenceEnabled((Boolean) message); audioSink.setSkipSilenceEnabled((Boolean) checkNotNull(message));
break; break;
case MSG_SET_AUDIO_SESSION_ID: case MSG_SET_AUDIO_SESSION_ID:
audioSink.setAudioSessionId((Integer) message); audioSink.setAudioSessionId((Integer) checkNotNull(message));
break; break;
case MSG_SET_WAKEUP_LISTENER: case MSG_SET_WAKEUP_LISTENER:
this.wakeupListener = (WakeupListener) message; this.wakeupListener = (WakeupListener) message;