Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix silent Dolby Atmos playback

Nathan Poulson7bd042f06dc0
diff --git a/packages/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java b/packages/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java
index 4e948be2..71e20150 100644
--- a/packages/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java
+++ b/packages/just_audio/android/src/main/java/com/ryanheise/just_audio/AudioPlayer.java
@@ -899,6 +899,45 @@ public class AudioPlayer implements MethodCallHandler, Player.Listener, Metadata
0.5f, 0.0f, // BL -> L, R
0.0f, 0.5f // BR -> L, R
}));
+ // Downmix Dolby Atmos 5.1.4 (10ch) to stereo. Hit when the
+ // Samsung Dolby E-AC-3 decoder mid-stream-upmixes a 5.1 base to
+ // add 4 height channels. Buffer order follows the channel mask
+ // bit order reported by c2.dolby.eac3.decoder (LSB first):
+ // FL, FR, FC, LFE, BL, BR, TFL, TFR, TBL, TBR
+ monoProcessor.putChannelMixingMatrix(
+ new androidx.media3.common.audio.ChannelMixingMatrix(10, 2, new float[]{
+ 1.0f, 0.0f, // FL -> L, R
+ 0.0f, 1.0f, // FR -> L, R
+ 0.707f, 0.707f, // FC -> L, R
+ 0.5f, 0.5f, // LFE -> L, R
+ 0.707f, 0.0f, // BL -> L, R
+ 0.0f, 0.707f, // BR -> L, R
+ 0.5f, 0.0f, // TFL -> L, R (height, -6 dB)
+ 0.0f, 0.5f, // TFR -> L, R
+ 0.354f, 0.0f, // TBL -> L, R (rear height, -9 dB)
+ 0.0f, 0.354f // TBR -> L, R
+ }));
+ // Downmix Dolby Atmos 7.1.4 (12ch) to stereo. This is the most
+ // common Atmos bed layout and is what Samsung's Dolby decoder
+ // produces for E-AC-3 JOC content after its CCodecWatchDolbyAtmos
+ // watcher upgrades the decoder from 5.1 to full Atmos output.
+ // Buffer order (mask-bit LSB first):
+ // FL, FR, FC, LFE, BL, BR, SL, SR, TFL, TFR, TBL, TBR
+ monoProcessor.putChannelMixingMatrix(
+ new androidx.media3.common.audio.ChannelMixingMatrix(12, 2, new float[]{
+ 1.0f, 0.0f, // FL -> L, R
+ 0.0f, 1.0f, // FR -> L, R
+ 0.707f, 0.707f, // FC -> L, R
+ 0.5f, 0.5f, // LFE -> L, R
+ 0.5f, 0.0f, // BL -> L, R
+ 0.0f, 0.5f, // BR -> L, R
+ 0.707f, 0.0f, // SL -> L, R
+ 0.0f, 0.707f, // SR -> L, R
+ 0.5f, 0.0f, // TFL -> L, R (height, -6 dB)
+ 0.0f, 0.5f, // TFR -> L, R
+ 0.354f, 0.0f, // TBL -> L, R (rear height, -9 dB)
+ 0.0f, 0.354f // TBR -> L, R
+ }));
sMonoProcessor = monoProcessor;
MonoController.register(AudioPlayer::setMonoEnabled);
RenderersFactory renderersFactory = new DefaultRenderersFactory(context) {