Snap for 12730349 from 9aab1380a87a0cedb35788e48016737805564a2d to 25Q1-release
Change-Id: I73724388c89909ff43cc1f64edec7b9ef196a3b2
diff --git a/media/libaudioclient/aidl/android/media/ISpatializer.aidl b/media/libaudioclient/aidl/android/media/ISpatializer.aidl
index 37dd776..4a5321e 100644
--- a/media/libaudioclient/aidl/android/media/ISpatializer.aidl
+++ b/media/libaudioclient/aidl/android/media/ISpatializer.aidl
@@ -163,4 +163,11 @@
* Gets the io handle of the output stream the spatializer is connected to.
*/
int getOutput();
+
+ /**
+ * Returns a list of channel masks that represent the widest channel masks the spatializer
+ * is capable of rendering with individual channel positions.
+ * Note that each channel mask is in the native format.
+ */
+ int[] getSpatializedChannelMasks();
}
diff --git a/services/audiopolicy/service/Spatializer.cpp b/services/audiopolicy/service/Spatializer.cpp
index c7740ad..d177b92 100644
--- a/services/audiopolicy/service/Spatializer.cpp
+++ b/services/audiopolicy/service/Spatializer.cpp
@@ -413,6 +413,29 @@
return BAD_VALUE;
}
+ std::vector<audio_channel_mask_t> spatializedChannelMasks;
+ status = getHalParameter<true>(effect, SPATIALIZER_PARAM_SPATIALIZED_CHANNEL_MASKS,
+ &spatializedChannelMasks);
+ if (status != NO_ERROR) {
+ ALOGW("%s: cannot get SPATIALIZER_PARAM_SPATIALIZED_CHANNEL_MASKS", __func__);
+ return status;
+ }
+ if (spatializedChannelMasks.empty()) {
+ ALOGW("%s: SPATIALIZER_PARAM_SPATIALIZED_CHANNEL_MASKS reports empty", __func__);
+ return BAD_VALUE;
+ }
+ for (const audio_channel_mask_t spatializedMask : spatializedChannelMasks) {
+ // spatialized masks must be contained in the supported input masks
+ if (std::find(mChannelMasks.begin(), mChannelMasks.end(), spatializedMask)
+ != mChannelMasks.end()) {
+ mSpatializedChannelMasks.emplace_back(spatializedMask);
+ } else {
+ ALOGE("%s: spatialized mask %#x not in list reported by PARAM_SUPPORTED_CHANNEL_MASKS",
+ __func__, spatializedMask);
+ return BAD_VALUE;
+ }
+ }
+
if (com::android::media::audio::dsa_over_bt_le_audio()
&& mSupportsHeadTracking) {
mHeadtrackingConnectionMode = HeadTracking::ConnectionMode::FRAMEWORK_PROCESSED;
@@ -474,6 +497,17 @@
return config;
}
+Status Spatializer::getSpatializedChannelMasks(std::vector<int>* masks) {
+ audio_utils::lock_guard lock(mMutex);
+ ALOGV("%s", __func__);
+ if (masks == nullptr) {
+ return binderStatusFromStatusT(BAD_VALUE);
+ }
+ masks->insert(masks->end(), mSpatializedChannelMasks.begin(),
+ mSpatializedChannelMasks.end());
+ return Status::ok();
+ }
+
status_t Spatializer::registerCallback(
const sp<media::INativeSpatializerCallback>& callback) {
audio_utils::lock_guard lock(mMutex);
@@ -1254,6 +1288,10 @@
for (auto& mask : mChannelMasks) {
base::StringAppendF(&ss, "%s", audio_channel_out_mask_to_string(mask));
}
+ base::StringAppendF(&ss, "%smSpatializedChannelMasks: ", prefixSpace.c_str());
+ for (auto& mask : mSpatializedChannelMasks) {
+ base::StringAppendF(&ss, "%s", audio_channel_out_mask_to_string(mask));
+ }
base::StringAppendF(&ss, "\n%smSupportsHeadTracking: %s\n", prefixSpace.c_str(),
mSupportsHeadTracking ? "true" : "false");
// 2. Settings (Output, tracks)
diff --git a/services/audiopolicy/service/Spatializer.h b/services/audiopolicy/service/Spatializer.h
index 5ea3258..6141165 100644
--- a/services/audiopolicy/service/Spatializer.h
+++ b/services/audiopolicy/service/Spatializer.h
@@ -133,6 +133,7 @@
binder::Status setParameter(int key, const std::vector<unsigned char>& value) override;
binder::Status getParameter(int key, std::vector<unsigned char> *value) override;
binder::Status getOutput(int *output);
+ binder::Status getSpatializedChannelMasks(std::vector<int>* masks) override;
/** IBinder::DeathRecipient. Listen to the death of the INativeSpatializerCallback. */
virtual void binderDied(const wp<IBinder>& who);
@@ -536,6 +537,7 @@
std::vector<media::audio::common::HeadTracking::Mode> mHeadTrackingModes;
std::vector<media::audio::common::Spatialization::Mode> mSpatializationModes;
std::vector<audio_channel_mask_t> mChannelMasks;
+ std::vector<audio_channel_mask_t> mSpatializedChannelMasks;
bool mSupportsHeadTracking;
/** List of supported head tracking connection modes reported by the spatializer.