From fb98968019431632f146223c33d63a21f300c9bc Mon Sep 17 00:00:00 2001 From: ybai001 Date: Wed, 3 Jun 2026 16:56:35 +0800 Subject: [PATCH] EAC3-JOC MIME type should not be taken as EAC3 on Pixel Device Pixel devices integrate an EAC3 decoder, but it does not support EAC3-JOC stream decoding. --- .../exoplayer/mediacodec/MediaCodecUtil.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.java index 8616e06a8db..5925f1942e9 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/MediaCodecUtil.java @@ -378,7 +378,9 @@ public static MediaCodecProfileAndLevel getHevcBaseLayerCodecProfileAndLevel(For public static String getAlternativeCodecMimeType(Format format) { if (MimeTypes.AUDIO_E_AC3_JOC.equals(format.sampleMimeType)) { // E-AC3 decoders can decode JOC streams, but in 2-D rather than 3-D. - return MimeTypes.AUDIO_E_AC3; + // Some devices (e.g. Pixel) integrate an EAC3 decoder that does not support EAC3-JOC + // stream decoding. + return supportsEac3JocFallbackDecoding() ? MimeTypes.AUDIO_E_AC3 : null; } if (MimeTypes.AUDIO_DTS_HD.equals(format.sampleMimeType) || MimeTypes.AUDIO_DTS_UHD_P2.equals(format.sampleMimeType)) { @@ -419,6 +421,25 @@ public static String getAlternativeCodecMimeType(Format format) { // Internal methods. + /** + * Returns whether the device supports decoding E-AC3 JOC streams using a standard E-AC3 decoder + * (in 2-D rather than 3-D). + * + *

Some devices (e.g. Pixel) have an E-AC3 decoder that cannot handle E-AC3 JOC streams at + * all, even in degraded 2-D mode. + */ + private static boolean supportsEac3JocFallbackDecoding() { + String manufacturer = Build.MANUFACTURER; + String brand = Build.BRAND; + String model = Build.MODEL; + + boolean isGoogle = + "Google".equalsIgnoreCase(manufacturer) && "google".equalsIgnoreCase(brand); + boolean isPixelModel = model != null && model.startsWith("Pixel"); + + return !(isGoogle && isPixelModel); + } + /** * Returns {@link MediaCodecInfo}s for the given codec {@link CodecKey} in the order given by * {@code mediaCodecList}.