summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2024-04-18 09:57:26 +0000
committer Eric Laurent <elaurent@google.com> 2024-04-25 01:34:29 +0000
commit25845858ad30965e1612e63148339ba1aff20a6e (patch)
tree8f84b2032c33bd6c7fa69ac78d966f0f3df59aa8
parent97a462b1948c9aacb6547290594f476a218f54e1 (diff)
SpatializerHelper: assimilate speaker safe to speaker device for SA compatibility
Although speaker safe is a mono device and should not be compatible with transaural spatilization, we consider it is to avoid transient SA availability changes propagated to apps that would cause failures to play SA content. This can happen for instance if ringtone playback is still active when the onRoutingUpdated() calback is called by APM due to an audio mode change. A better longer term solution would be to trigger the onRoutingUpdated() callback more dynamically each time the media routing changes but the impact on performance and other consumers of this callback must be investigated. Bug: 331349123 Test: repro steps in the bug Change-Id: Id5d48427ff4ecef02a01a6e7fe46c5f910825e81 Merged-In: Id5d48427ff4ecef02a01a6e7fe46c5f910825e81
-rw-r--r--services/core/java/com/android/server/audio/SpatializerHelper.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/audio/SpatializerHelper.java b/services/core/java/com/android/server/audio/SpatializerHelper.java
index 38fa79f7f44a..e2c4b4638207 100644
--- a/services/core/java/com/android/server/audio/SpatializerHelper.java
+++ b/services/core/java/com/android/server/audio/SpatializerHelper.java
@@ -88,6 +88,10 @@ public class SpatializerHelper {
/*package*/ static final SparseIntArray SPAT_MODE_FOR_DEVICE_TYPE = new SparseIntArray(14) {
{
append(AudioDeviceInfo.TYPE_BUILTIN_SPEAKER, Spatialization.Mode.TRANSAURAL);
+ // Speaker safe is considered compatible with spatial audio because routing media usage
+ // to speaker safe only happens in transient situations and should not affect app
+ // decisions to play spatial audio content.
+ append(AudioDeviceInfo.TYPE_BUILTIN_SPEAKER_SAFE, Spatialization.Mode.TRANSAURAL);
append(AudioDeviceInfo.TYPE_WIRED_HEADSET, Spatialization.Mode.BINAURAL);
append(AudioDeviceInfo.TYPE_WIRED_HEADPHONES, Spatialization.Mode.BINAURAL);
// assumption for A2DP: mostly headsets
@@ -805,7 +809,7 @@ 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
+ // spatial audio. For instance mono devices like earpiece or sco must
// not be included.
final byte modeForDevice = (byte) SPAT_MODE_FOR_DEVICE_TYPE.get(ada.getType(),
/*default when type not found*/ -1);