summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikhil Bhanu <nikhilbhanu@google.com>2023-11-21 16:34:25 -0800
committerShunkai Yao <yaoshunkai@google.com>2024-02-08 17:14:42 +0000
commite0283c632d005ebe1cae13eeb4a165ed46fb3dc0 (patch)
tree67e6330fd7342837db1e68962ce441afc24b5c53
parent1d199ce8e42e5a05e8bb076bc636d60bac18efa6 (diff)
downloadmedia-e0283c632d005ebe1cae13eeb4a165ed46fb3dc0.tar.gz
audio: add audio_channel_mask_contains_stereo
This is used to determine track channel mask eligibility for stereo spatialization. Bug: 303920722 Test: manual Merged-In: I33e92a4341e7d265cec07237db4538e4629076d4 Change-Id: I33e92a4341e7d265cec07237db4538e4629076d4
-rw-r--r--audio/include/system/audio.h18
-rw-r--r--audio/include/system/audio_effects/effect_spatializer.h9
2 files changed, 26 insertions, 1 deletions
diff --git a/audio/include/system/audio.h b/audio/include/system/audio.h
index 826c1a22..2979ba3f 100644
--- a/audio/include/system/audio.h
+++ b/audio/include/system/audio.h
@@ -332,6 +332,24 @@ static inline CONSTEXPR audio_channel_mask_t audio_channel_mask_from_representat
}
/*
+ * Returns true so long as stereo channels are present in the channel mask.
+ *
+ * This is the minimum constraint for spatialization in Android V.
+ *
+ * Prior to V, AUDIO_CHANNEL_OUT_QUAD was the minimum constraint.
+ * Prior to T, AUDIO_CHANNEL_OUT_5POINT1 was the minimum constraint.
+ *
+ * TODO(b/303920722) rename to audio_is_channel_mask_spatialized() after testing
+ * is complete.
+ * TODO(b/316909431) flagged at caller due to lack of native_bridge flag support.
+ */
+static inline CONSTEXPR bool audio_channel_mask_contains_stereo(audio_channel_mask_t channelMask) {
+ return audio_channel_mask_get_representation(channelMask)
+ == AUDIO_CHANNEL_REPRESENTATION_POSITION
+ && (channelMask & AUDIO_CHANNEL_OUT_STEREO) == AUDIO_CHANNEL_OUT_STEREO;
+}
+
+/*
* Returns true so long as Quadraphonic channels (FL, FR, BL, BR)
* or (FL, FR, SL, SR) are completely specified
* in the channel mask. We expect these 4 channels to be the minimum for
diff --git a/audio/include/system/audio_effects/effect_spatializer.h b/audio/include/system/audio_effects/effect_spatializer.h
index b92bb50d..2035d45f 100644
--- a/audio/include/system/audio_effects/effect_spatializer.h
+++ b/audio/include/system/audio_effects/effect_spatializer.h
@@ -86,7 +86,14 @@ typedef enum
// Set/get the head tracking data connection mode: passes the mode followed by the sensor ID
// on uint32_t
- SPATIALIZER_PARAM_HEADTRACKING_CONNECTION
+ SPATIALIZER_PARAM_HEADTRACKING_CONNECTION,
+ // Set/get the actual input channel mask of the track being spatialized. This is required to
+ // support stereo spatialization (b/303920722) where number of active input channels would be
+ // different from the channel mask received during effect configuration.
+ // Stereo channels will be packed into 5.1 stream where the other 4 channels will contain
+ // silence. The effect can configure spatialization settings accordingly when this parameter is
+ // received.
+ SPATIALIZER_PARAM_INPUT_CHANNEL_MASK,
} t_virtualizer_stage_params;
// See SpatializationLevel.aidl