audio: Align Module::getMmapPolicyInfos behavior with legacy

When there are no device ports supporting MMAP,
Module::getMmapPolicyInfos have to return 'Policy::NEVER'
so that the AAudio code does not attempt to use
the AAudio service. This aligns with the use of sysprops
by the HIDL implementation.

Update AudioCoreModule#GetMmapPolicyInfos test to use
the same logic for determining MMAP support as the framework
uses.

This makes CtsNativeMediaAAudioTest cases passing with
the AIDL HAL on Cuttlefish.

Bug: 302049825
Test: atest VtsHalAudioCoreTargetTest
Test: atest CtsNativeMediaAAudioTest [w/AIDL enabled on CF]
Change-Id: Ie58c408f6f648a8a03b6a5d92118b90061389c50
This commit is contained in:
Mikhail Naganov 2023-09-26 17:10:08 -07:00
parent 87e6b60eb3
commit 8506491475
2 changed files with 14 additions and 1 deletions

View file

@ -1277,6 +1277,12 @@ ndk::ScopedAStatus Module::getMmapPolicyInfos(AudioMMapPolicyType mmapPolicyType
mmapSources.insert(port.id);
}
}
if (mmapSources.empty() && mmapSinks.empty()) {
AudioMMapPolicyInfo never;
never.mmapPolicy = AudioMMapPolicy::NEVER;
_aidl_return->push_back(never);
return ndk::ScopedAStatus::ok();
}
for (const auto& route : getConfig().routes) {
if (mmapSinks.count(route.sinkPortId) != 0) {
// The sink is a mix port, add the sources if they are device ports.

View file

@ -87,6 +87,7 @@ using aidl::android::media::audio::common::AudioDualMonoMode;
using aidl::android::media::audio::common::AudioFormatType;
using aidl::android::media::audio::common::AudioIoFlags;
using aidl::android::media::audio::common::AudioLatencyMode;
using aidl::android::media::audio::common::AudioMMapPolicy;
using aidl::android::media::audio::common::AudioMMapPolicyInfo;
using aidl::android::media::audio::common::AudioMMapPolicyType;
using aidl::android::media::audio::common::AudioMode;
@ -2133,7 +2134,13 @@ TEST_P(AudioCoreModule, GetMmapPolicyInfos) {
std::vector<AudioMMapPolicyInfo> policyInfos;
EXPECT_IS_OK(module->getMmapPolicyInfos(mmapPolicyType, &policyInfos))
<< toString(mmapPolicyType);
EXPECT_EQ(isMmapSupported, !policyInfos.empty());
const bool isMMapSupportedByPolicyInfos =
std::find_if(policyInfos.begin(), policyInfos.end(), [](const auto& info) {
return info.mmapPolicy == AudioMMapPolicy::AUTO ||
info.mmapPolicy == AudioMMapPolicy::ALWAYS;
}) != policyInfos.end();
EXPECT_EQ(isMmapSupported, isMMapSupportedByPolicyInfos)
<< ::android::internal::ToString(policyInfos);
}
}