mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Ensure audio renderer exceptions report the correct format.
PiperOrigin-RevId: 322534950
This commit is contained in:
parent
6c837643b9
commit
193306f2f3
@ -255,7 +255,11 @@ public abstract class DecoderAudioRenderer extends BaseRenderer implements Media
|
||||
// End of stream read having not read a format.
|
||||
Assertions.checkState(flagsOnlyBuffer.isEndOfStream());
|
||||
inputStreamEnded = true;
|
||||
processEndOfStream();
|
||||
try {
|
||||
processEndOfStream();
|
||||
} catch (AudioSink.WriteException e) {
|
||||
throw createRendererException(e, /* format= */ null);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
// 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
|
||||
} else {
|
||||
outputBuffer.release();
|
||||
outputBuffer = null;
|
||||
processEndOfStream();
|
||||
try {
|
||||
processEndOfStream();
|
||||
} catch (AudioSink.WriteException e) {
|
||||
throw createRendererException(e, getOutputFormat());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -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;
|
||||
try {
|
||||
audioSink.playToEndOfStream();
|
||||
} catch (AudioSink.WriteException e) {
|
||||
// TODO(internal: b/145658993) Use outputFormat for the call from drainOutputBuffer.
|
||||
throw createRendererException(e, inputFormat);
|
||||
}
|
||||
audioSink.playToEndOfStream();
|
||||
}
|
||||
|
||||
private void flushDecoder() throws ExoPlaybackException {
|
||||
|
@ -634,8 +634,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
||||
try {
|
||||
fullyConsumed = audioSink.handleBuffer(buffer, bufferPresentationTimeUs, sampleCount);
|
||||
} catch (AudioSink.InitializationException | AudioSink.WriteException e) {
|
||||
// TODO(internal: b/145658993) Use outputFormat instead.
|
||||
throw createRendererException(e, inputFormat);
|
||||
throw createRendererException(e, format);
|
||||
}
|
||||
|
||||
if (fullyConsumed) {
|
||||
@ -654,8 +653,8 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
||||
try {
|
||||
audioSink.playToEndOfStream();
|
||||
} catch (AudioSink.WriteException e) {
|
||||
// TODO(internal: b/145658993) Use outputFormat instead.
|
||||
throw createRendererException(e, inputFormat);
|
||||
Format outputFormat = getCurrentOutputFormat();
|
||||
throw createRendererException(e, outputFormat != null ? outputFormat : inputFormat);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user