Commit 193306f2 by samrobinson Committed by Oliver Woodman

Ensure audio renderer exceptions report the correct format.

PiperOrigin-RevId: 322534950
parent 6c837643
...@@ -255,7 +255,11 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media ...@@ -255,7 +255,11 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
// End of stream read having not read a format. // End of stream read having not read a format.
Assertions.checkState(flagsOnlyBuffer.isEndOfStream()); Assertions.checkState(flagsOnlyBuffer.isEndOfStream());
inputStreamEnded = true; inputStreamEnded = true;
processEndOfStream(); try {
processEndOfStream();
} catch (AudioSink.WriteException e) {
throw createRendererException(e, /* format= */ null);
}
return; return;
} else { } else {
// We still don't have a format and can't make progress without one. // We still don't have a format and can't make progress without one.
...@@ -356,7 +360,11 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media ...@@ -356,7 +360,11 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
} else { } else {
outputBuffer.release(); outputBuffer.release();
outputBuffer = null; outputBuffer = null;
processEndOfStream(); try {
processEndOfStream();
} catch (AudioSink.WriteException e) {
throw createRendererException(e, getOutputFormat());
}
} }
return false; return false;
} }
...@@ -431,14 +439,9 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media ...@@ -431,14 +439,9 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
} }
} }
private void processEndOfStream() throws ExoPlaybackException { private void processEndOfStream() throws AudioSink.WriteException {
outputStreamEnded = true; outputStreamEnded = true;
try { audioSink.playToEndOfStream();
audioSink.playToEndOfStream();
} catch (AudioSink.WriteException e) {
// TODO(internal: b/145658993) Use outputFormat for the call from drainOutputBuffer.
throw createRendererException(e, inputFormat);
}
} }
private void flushDecoder() throws ExoPlaybackException { private void flushDecoder() throws ExoPlaybackException {
......
...@@ -634,8 +634,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media ...@@ -634,8 +634,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
try { try {
fullyConsumed = audioSink.handleBuffer(buffer, bufferPresentationTimeUs, sampleCount); fullyConsumed = audioSink.handleBuffer(buffer, bufferPresentationTimeUs, sampleCount);
} catch (AudioSink.InitializationException | AudioSink.WriteException e) { } catch (AudioSink.InitializationException | AudioSink.WriteException e) {
// TODO(internal: b/145658993) Use outputFormat instead. throw createRendererException(e, format);
throw createRendererException(e, inputFormat);
} }
if (fullyConsumed) { if (fullyConsumed) {
...@@ -654,8 +653,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media ...@@ -654,8 +653,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
try { try {
audioSink.playToEndOfStream(); audioSink.playToEndOfStream();
} catch (AudioSink.WriteException e) { } catch (AudioSink.WriteException e) {
// TODO(internal: b/145658993) Use outputFormat instead. Format outputFormat = getCurrentOutputFormat();
throw createRendererException(e, inputFormat); throw createRendererException(e, outputFormat != null ? outputFormat : inputFormat);
} }
} }
......
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