From b40da57cac61a26475df1d1578607ab94ab7166a Mon Sep 17 00:00:00 2001 From: Edison Wang Date: Tue, 23 Sep 2014 14:53:07 -0400 Subject: [PATCH] Fix for devices that report incorrect supported types. Certain devices can report a codec in the supported list but don't really support it. getCapabilitiesForType will return IllegalArgument and we shouldn't add it to the list. --- .../com/google/android/exoplayer/MediaCodecUtil.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java b/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java index 31ec2ae9f15..f7a7b54594a 100644 --- a/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java +++ b/library/src/main/java/com/google/android/exoplayer/MediaCodecUtil.java @@ -81,8 +81,14 @@ private static synchronized Pair getMediaCode for (int j = 0; j < supportedTypes.length; j++) { String supportedType = supportedTypes[j]; if (supportedType.equalsIgnoreCase(mimeType)) { - result = Pair.create(info, info.getCapabilitiesForType(supportedType)); - codecs.put(mimeType, result); + try { + result = Pair.create(info, info.getCapabilitiesForType(supportedType)); + codecs.put(mimeType, result); + } catch (IllegalArgumentException e) { + //Certain devices can report a codec in the supported list but don't really support it. + //getCapabilitiesForType will return IllegalArgument and we shouldn't add it to the list. + continue; + } return result; } }