audio policy: set track spatialization state from audio policy manager.
When an audio track is created, AudioPolicyManager.getOutputForAttr()
will return if it is actually being spatialized. This will allow removing
the duplicated logic in audio flinger to tell if a track is spatialized and
also to only enable the spatializer effect if spatialized tracks are active
and connected to the spatializer mixer.
Bug: 227740874
Test: music and spatial audio playback regression
Change-Id: If75c8ad06afdf3b47e3cc5d30c777af22d6fc35e
diff --git a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
index c9cfbca..df49bba 100644
--- a/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp
@@ -383,13 +383,15 @@
AutoCallerClear acc;
AudioPolicyInterface::output_type_t outputType;
+ bool isSpatialized = false;
status_t result = mAudioPolicyManager->getOutputForAttr(&attr, &output, session,
&stream,
adjAttributionSource,
&config,
&flags, &selectedDeviceId, &portId,
&secondaryOutputs,
- &outputType);
+ &outputType,
+ &isSpatialized);
// FIXME: Introduce a way to check for the the telephony device before opening the output
if (result == NO_ERROR) {
@@ -426,7 +428,7 @@
if (result == NO_ERROR) {
sp<AudioPlaybackClient> client =
new AudioPlaybackClient(attr, output, adjAttributionSource, session,
- portId, selectedDeviceId, stream);
+ portId, selectedDeviceId, stream, isSpatialized);
mAudioPlaybackClients.add(portId, client);
_aidl_return->output = VALUE_OR_RETURN_BINDER_STATUS(
@@ -440,6 +442,7 @@
_aidl_return->secondaryOutputs = VALUE_OR_RETURN_BINDER_STATUS(
convertContainer<std::vector<int32_t>>(secondaryOutputs,
legacy2aidl_audio_io_handle_t_int32_t));
+ _aidl_return->isSpatialized = isSpatialized;
}
return binderStatusFromStatusT(result);
}