mirror of
https://github.com/androidx/media.git
synced 2025-05-07 15:40:37 +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.
|
// End of stream read having not read a format.
|
||||||
Assertions.checkState(flagsOnlyBuffer.isEndOfStream());
|
Assertions.checkState(flagsOnlyBuffer.isEndOfStream());
|
||||||
inputStreamEnded = true;
|
inputStreamEnded = true;
|
||||||
|
try {
|
||||||
processEndOfStream();
|
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
|
|||||||
} else {
|
} else {
|
||||||
outputBuffer.release();
|
outputBuffer.release();
|
||||||
outputBuffer = null;
|
outputBuffer = null;
|
||||||
|
try {
|
||||||
processEndOfStream();
|
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
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
|||||||
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
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user