Change format logged when AudioSink throws InitializationException

Change what format is logged from MediaCodecAudioRenderer when
AudioSink throws InitializationException. We printed the
AudioSink's format, which most of the times is audio/raw (PCM)
and not the renderer's format. With this change both formats are
logged.

#minor-release

Issue: google/ExoPlayer#11066
PiperOrigin-RevId: 523456840
(cherry picked from commit baf1aa1cdbe626097c7fa310047edac7033f2ffe)
This commit is contained in:
christosts 2023-04-11 19:25:33 +01:00 committed by Rohit Singh
parent 0690c9ba67
commit abc9d8ceda
2 changed files with 7 additions and 2 deletions

View File

@ -189,6 +189,8 @@ public interface AudioSink {
+ audioTrackState + audioTrackState
+ " " + " "
+ ("Config(" + sampleRate + ", " + channelConfig + ", " + bufferSize + ")") + ("Config(" + sampleRate + ", " + channelConfig + ", " + bufferSize + ")")
+ " "
+ format
+ (isRecoverable ? " (recoverable)" : ""), + (isRecoverable ? " (recoverable)" : ""),
audioTrackException); audioTrackException);
this.audioTrackState = audioTrackState; this.audioTrackState = audioTrackState;

View File

@ -105,6 +105,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
private int codecMaxInputSize; private int codecMaxInputSize;
private boolean codecNeedsDiscardChannelsWorkaround; private boolean codecNeedsDiscardChannelsWorkaround;
@Nullable private Format inputFormat;
/** Codec used for DRM decryption only in passthrough and offload. */ /** Codec used for DRM decryption only in passthrough and offload. */
@Nullable private Format decryptOnlyCodecFormat; @Nullable private Format decryptOnlyCodecFormat;
@ -500,8 +501,9 @@ 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);
@Nullable DecoderReuseEvaluation evaluation = super.onInputFormatChanged(formatHolder); @Nullable DecoderReuseEvaluation evaluation = super.onInputFormatChanged(formatHolder);
eventDispatcher.inputFormatChanged(formatHolder.format, evaluation); eventDispatcher.inputFormatChanged(inputFormat, evaluation);
return evaluation; return evaluation;
} }
@ -604,6 +606,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
@Override @Override
protected void onDisabled() { protected void onDisabled() {
audioSinkNeedsReset = true; audioSinkNeedsReset = true;
inputFormat = null;
try { try {
audioSink.flush(); audioSink.flush();
} finally { } finally {
@ -711,7 +714,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
fullyConsumed = audioSink.handleBuffer(buffer, bufferPresentationTimeUs, sampleCount); fullyConsumed = audioSink.handleBuffer(buffer, bufferPresentationTimeUs, sampleCount);
} catch (InitializationException e) { } catch (InitializationException e) {
throw createRendererException( throw createRendererException(
e, e.format, e.isRecoverable, PlaybackException.ERROR_CODE_AUDIO_TRACK_INIT_FAILED); e, inputFormat, e.isRecoverable, PlaybackException.ERROR_CODE_AUDIO_TRACK_INIT_FAILED);
} catch (WriteException e) { } catch (WriteException e) {
throw createRendererException( throw createRendererException(
e, format, e.isRecoverable, PlaybackException.ERROR_CODE_AUDIO_TRACK_WRITE_FAILED); e, format, e.isRecoverable, PlaybackException.ERROR_CODE_AUDIO_TRACK_WRITE_FAILED);