Commit 169f23ff authored by boliu's avatar boliu Committed by Commit bot

android: Swallow MediaCodecList constructor exception

Bad android implementation can sometimes throw exceptions. Just swallow
it and pretend MediaCodecList is not supported.

BUG=695248, 709631

Review-Url: https://codereview.chromium.org/2817663004
Cr-Commit-Position: refs/heads/master@{#464270}
parent ace0d4cd
......@@ -68,8 +68,13 @@ class MediaCodecUtil {
private static class MediaCodecListHelper implements Iterable<MediaCodecInfo> {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public MediaCodecListHelper() {
if (hasNewMediaCodecList()) {
mCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS).getCodecInfos();
if (supportsNewMediaCodecList()) {
try {
mCodecList = new MediaCodecList(MediaCodecList.ALL_CODECS).getCodecInfos();
} catch (RuntimeException e) {
// Swallow the exception due to bad Android implementation and pretend
// MediaCodecList is not supported.
}
}
}
......@@ -90,10 +95,14 @@ class MediaCodecUtil {
return MediaCodecList.getCodecInfoAt(index);
}
private boolean hasNewMediaCodecList() {
private static boolean supportsNewMediaCodecList() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
}
private boolean hasNewMediaCodecList() {
return supportsNewMediaCodecList() && mCodecList != null;
}
private MediaCodecInfo[] mCodecList;
private class CodecInfoIterator implements Iterator<MediaCodecInfo> {
......
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 to comment