From 657703e4b024986ecbe1b0d98b3c9460bab655b8 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Thu, 3 Mar 2022 15:29:15 +0000 Subject: [PATCH] Fix E-AC3 output capability check without sample rate PiperOrigin-RevId: 432189509 (cherry picked from commit e66d0c9039dec5d60afd930c10520db5ccf08121) --- RELEASENOTES.md | 3 +++ .../google/android/exoplayer2/audio/DefaultAudioSink.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 4376c47a81..8d8c16ef35 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -2,6 +2,9 @@ ### dev-v2 (not yet released) +* Audio: + * Fix error checking audio capabilities for Dolby Atmos (E-AC3-JOC) in + HLS. * Extractors: * FMP4: Fix issue where emsg sample metadata could be output in the wrong order for streams containing both v0 and v1 emsg atoms diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java index 72b4b9da9c..ccccc5301a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java @@ -1730,8 +1730,11 @@ public final class DefaultAudioSink implements AudioSink { // the channel count for this encoding, but before then there is no way to query it so we // assume 6 channel audio is supported. if (Util.SDK_INT >= 29) { + // Default to 48 kHz if the format doesn't have a sample rate (for example, for chunkless + // HLS preparation). See [Internal: b/222127949]. + int sampleRate = format.sampleRate != Format.NO_VALUE ? format.sampleRate : 48000; channelCount = - getMaxSupportedChannelCountForPassthroughV29(C.ENCODING_E_AC3_JOC, format.sampleRate); + getMaxSupportedChannelCountForPassthroughV29(C.ENCODING_E_AC3_JOC, sampleRate); if (channelCount == 0) { Log.w(TAG, "E-AC3 JOC encoding supported but no channel count supported"); return null;