Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(869)

Unified Diff: media/base/android/java/src/org/chromium/media/MediaCodecUtil.java

Issue 2817663004: android: Swallow MediaCodecList constructor exception (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
diff --git a/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java b/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
index 0c0d469e25459f0c6cf0efae2148e2345b3aa2c8..1ea6aa2b57a9dd7285383333c261335a58cf9677 100644
--- a/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
+++ b/media/base/android/java/src/org/chromium/media/MediaCodecUtil.java
@@ -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> {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698