Use device for given attributes to query direct playback support.
When querying the direct playback support with given audio attributes,
no device information will be taken into consideration when getting
compatible profiles. This will cause the problem that the direct
playback is supported with given audio attributes but the app may not
get direct playback with the same audio attibutes. The reason is that
the routed device(s) may not support direct playback with the audio
attibutes while some other devices do but they are not the routed
devices. In that case, when querying direct playback support, the
devices for given attributes should be used.
Bug: 196047314
Test: atest AudioManagerTest AudioTrackOffloadTest
Change-Id: Idf7d1f5fff44ee542254e72c8251c34a8fe652ff
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index cc1012c..607ea49 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -3782,9 +3782,10 @@
}
flags = (audio_output_flags_t)((flags & relevantFlags) | AUDIO_OUTPUT_FLAG_DIRECT);
+ DeviceVector outputDevices = mEngine->getOutputDevicesForAttributes(*attr);
for (const auto& hwModule : mHwModules) {
for (const auto& curProfile : hwModule->getOutputProfiles()) {
- if (!curProfile->isCompatibleProfile(DeviceVector(),
+ if (!curProfile->isCompatibleProfile(outputDevices,
config->sample_rate, nullptr /*updatedSamplingRate*/,
config->format, nullptr /*updatedFormat*/,
config->channel_mask, nullptr /*updatedChannelMask*/,