mirror of
https://github.com/androidx/media.git
synced 2025-05-10 00:59:51 +08:00
Avoid using OMX.qcom.audio.decoder.mp3 on HTC Butterfly.
This OMX component is listed but can't be instantiated on this device. According to the GitHub issue, some other devices are also affected, so these will have to be added too. Issue: #377
This commit is contained in:
parent
5c9c15ae6e
commit
99edc6a4b4
@ -134,8 +134,7 @@ public class MediaCodecUtil {
|
|||||||
for (int i = 0; i < numberOfCodecs; i++) {
|
for (int i = 0; i < numberOfCodecs; i++) {
|
||||||
MediaCodecInfo info = mediaCodecList.getCodecInfoAt(i);
|
MediaCodecInfo info = mediaCodecList.getCodecInfoAt(i);
|
||||||
String codecName = info.getName();
|
String codecName = info.getName();
|
||||||
if (!info.isEncoder() && codecName.startsWith("OMX.")
|
if (isCodecUsableDecoder(info, codecName, secureDecodersExplicit)) {
|
||||||
&& (secureDecodersExplicit || !codecName.endsWith(".secure"))) {
|
|
||||||
String[] supportedTypes = info.getSupportedTypes();
|
String[] supportedTypes = info.getSupportedTypes();
|
||||||
for (int j = 0; j < supportedTypes.length; j++) {
|
for (int j = 0; j < supportedTypes.length; j++) {
|
||||||
String supportedType = supportedTypes[j];
|
String supportedType = supportedTypes[j];
|
||||||
@ -166,6 +165,28 @@ public class MediaCodecUtil {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the specified codec is usable for decoding on the current device.
|
||||||
|
*/
|
||||||
|
private static boolean isCodecUsableDecoder(MediaCodecInfo info, String name,
|
||||||
|
boolean secureDecodersExplicit) {
|
||||||
|
if (info.isEncoder() || !name.startsWith("OMX.")
|
||||||
|
|| (!secureDecodersExplicit && name.endsWith(".secure"))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Workaround an issue where creating a particular MP3 decoder on some HTC devices on platform
|
||||||
|
// API version 16 crashes mediaserver.
|
||||||
|
if (Util.SDK_INT == 16
|
||||||
|
&& ("dlxu".equals(Util.PRODUCT) // HTC Butterfly
|
||||||
|
|| "protou".equals(Util.PRODUCT)) // HTC Desire X
|
||||||
|
&& name.equals("OMX.qcom.audio.decoder.mp3")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isAdaptive(CodecCapabilities capabilities) {
|
private static boolean isAdaptive(CodecCapabilities capabilities) {
|
||||||
if (Util.SDK_INT >= 19) {
|
if (Util.SDK_INT >= 19) {
|
||||||
return isAdaptiveV19(capabilities);
|
return isAdaptiveV19(capabilities);
|
||||||
|
@ -59,6 +59,12 @@ public final class Util {
|
|||||||
*/
|
*/
|
||||||
public static final int SDK_INT = android.os.Build.VERSION.SDK_INT;
|
public static final int SDK_INT = android.os.Build.VERSION.SDK_INT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Like {@link android.os.Build#PRODUCT}, but in a place where it can be conveniently overridden
|
||||||
|
* for local testing.
|
||||||
|
*/
|
||||||
|
public static final String PRODUCT = android.os.Build.PRODUCT;
|
||||||
|
|
||||||
private static final Pattern XS_DATE_TIME_PATTERN = Pattern.compile(
|
private static final Pattern XS_DATE_TIME_PATTERN = Pattern.compile(
|
||||||
"(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt]"
|
"(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt]"
|
||||||
+ "(\\d\\d):(\\d\\d):(\\d\\d)(\\.(\\d+))?"
|
+ "(\\d\\d):(\\d\\d):(\\d\\d)(\\.(\\d+))?"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user