From 8dcc14f26ff06abdaee91edbd61d49283e000943 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 19 Aug 2022 14:46:23 +0200 Subject: [PATCH] SpatializerHelper: Fix device compatibility with spatial audio Do not consider BT SCO devices as compatible with spatial audio. This is justified because SCO is mono by nature. It also fixes the problem of having two devices with the same mac address but conflicting spatial audio settings. Bug: 242777739 Test: verify head tracking still works after a phone call Merged-In: I1918f8ec82e1d79416804a6ec47df7181b0d79eb Change-Id: I1918f8ec82e1d79416804a6ec47df7181b0d79eb --- .../java/com/android/server/audio/SpatializerHelper.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/audio/SpatializerHelper.java b/services/core/java/com/android/server/audio/SpatializerHelper.java index dd44af1b68eea..e4fdea742c5b8 100644 --- a/services/core/java/com/android/server/audio/SpatializerHelper.java +++ b/services/core/java/com/android/server/audio/SpatializerHelper.java @@ -709,8 +709,11 @@ public class SpatializerHelper { } private boolean isDeviceCompatibleWithSpatializationModes(@NonNull AudioDeviceAttributes ada) { + // modeForDevice will be neither transaural or binaural for devices that do not support + // spatial audio. For instance mono devices like earpiece, speaker safe or sco must + // not be included. final byte modeForDevice = (byte) SPAT_MODE_FOR_DEVICE_TYPE.get(ada.getType(), - /*default when type not found*/ SpatializationMode.SPATIALIZER_BINAURAL); + /*default when type not found*/ -1); if ((modeForDevice == SpatializationMode.SPATIALIZER_BINAURAL && mBinauralSupported) || (modeForDevice == SpatializationMode.SPATIALIZER_TRANSAURAL && mTransauralSupported)) { @@ -1532,8 +1535,8 @@ public class SpatializerHelper { @Override public String toString() { - return "type:" + mDeviceType + " addr:" + mDeviceAddress + " enabled:" + mEnabled - + " HT:" + mHasHeadTracker + " HTenabled:" + mHeadTrackerEnabled; + return "type: " + mDeviceType + " addr: " + mDeviceAddress + " enabled: " + mEnabled + + " HT: " + mHasHeadTracker + " HTenabled: " + mHeadTrackerEnabled; } String toPersistableString() {