Skip to content

Commit

Permalink
Change format logged when AudioSink throws InitializationException
Browse files Browse the repository at this point in the history
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
  • Loading branch information
christosts authored and rohitjoins committed Apr 12, 2023
1 parent 32be985 commit baf1aa1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public InitializationException(
+ audioTrackState
+ " "
+ ("Config(" + sampleRate + ", " + channelConfig + ", " + bufferSize + ")")
+ " "
+ format
+ (isRecoverable ? " (recoverable)" : ""),
audioTrackException);
this.audioTrackState = audioTrackState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media

private int codecMaxInputSize;
private boolean codecNeedsDiscardChannelsWorkaround;
@Nullable private Format inputFormat;
/** Codec used for DRM decryption only in passthrough and offload. */
@Nullable private Format decryptOnlyCodecFormat;

Expand Down Expand Up @@ -500,8 +501,9 @@ protected void onCodecError(Exception codecError) {
@Nullable
protected DecoderReuseEvaluation onInputFormatChanged(FormatHolder formatHolder)
throws ExoPlaybackException {
inputFormat = checkNotNull(formatHolder.format);
@Nullable DecoderReuseEvaluation evaluation = super.onInputFormatChanged(formatHolder);
eventDispatcher.inputFormatChanged(formatHolder.format, evaluation);
eventDispatcher.inputFormatChanged(inputFormat, evaluation);
return evaluation;
}

Expand Down Expand Up @@ -604,6 +606,7 @@ protected void onStopped() {
@Override
protected void onDisabled() {
audioSinkNeedsReset = true;
inputFormat = null;
try {
audioSink.flush();
} finally {
Expand Down Expand Up @@ -716,7 +719,7 @@ protected boolean processOutputBuffer(
fullyConsumed = audioSink.handleBuffer(buffer, bufferPresentationTimeUs, sampleCount);
} catch (InitializationException e) {
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) {
throw createRendererException(
e, format, e.isRecoverable, PlaybackException.ERROR_CODE_AUDIO_TRACK_WRITE_FAILED);
Expand Down

0 comments on commit baf1aa1

Please sign in to comment.