Only try to recover from CodecExceptions or IllegalStateExceptions

This commit is contained in:
Cameron Gutman
2022-09-18 00:20:41 -05:00
parent 33c1f0a71c
commit 06099b2663
@@ -618,8 +618,7 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
return false; return false;
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && e instanceof CodecException) {
if (e instanceof CodecException) {
CodecException codecExc = (CodecException) e; CodecException codecExc = (CodecException) e;
if (codecExc.isTransient()) { if (codecExc.isTransient()) {
@@ -643,15 +642,20 @@ public class MediaCodecDecoderRenderer extends VideoDecoderRenderer implements C
return false; return false;
} }
} }
} else if (e instanceof IllegalStateException) {
// IllegalStateException was primarily used prior to the introduction of CodecException.
// If we got here, this is most likely an IllegalStateException which was used prior to L // Recovery from this requires a full decoder reset.
// to indicate codec errors (unexpected transition to the error state). Recovery from this //
// requires a full decoder reset. // NB: CodecException is an IllegalStateException, so we must check for it first.
if (codecRecoveryAttempts < CR_MAX_TRIES) { if (codecRecoveryAttempts < CR_MAX_TRIES) {
needsReset = true; needsReset = true;
return false; return false;
} }
}
else {
// If it's not a CodecException or IllegalStateException, it's not an "expected" failure.
throw e;
}
// Only throw if we're not in the middle of codec recovery // Only throw if we're not in the middle of codec recovery
if (!needsReset && !needsRestart) { if (!needsReset && !needsRestart) {