Loading audio/core/all-versions/vts/functional/6.0/Generators.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -36,9 +36,14 @@ using namespace ::android::hardware::audio::CPP_VERSION; std::vector<DeviceConfigParameter> generateOutputDeviceConfigParameters(bool oneProfilePerDevice) { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); const std::string moduleName = std::get<PARAM_DEVICE_NAME>(device); auto module = getCachedPolicyConfig().getModuleFromName(moduleName); for (const auto& ioProfile : module->getOutputProfiles()) { if (getCachedPolicyConfig() .getAttachedSinkDeviceForMixPort(moduleName, ioProfile->getName()) .empty()) { continue; // no attached device } for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); Loading Loading @@ -94,9 +99,14 @@ const std::vector<DeviceConfigParameter>& getOutputDeviceSingleConfigParameters( std::vector<DeviceConfigParameter> generateInputDeviceConfigParameters(bool oneProfilePerDevice) { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); const std::string moduleName = std::get<PARAM_DEVICE_NAME>(device); auto module = getCachedPolicyConfig().getModuleFromName(moduleName); for (const auto& ioProfile : module->getInputProfiles()) { if (getCachedPolicyConfig() .getAttachedSourceDeviceForMixPort(moduleName, ioProfile->getName()) .empty()) { continue; // no attached device } for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); Loading audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp +6 −21 Original line number Diff line number Diff line Loading @@ -499,18 +499,10 @@ static const std::vector<DeviceConfigParameter>& getOutputDevicePcmOnlyConfigPar return xsd::isLinearPcm(std::get<PARAM_CONFIG>(cfg).base.format) // MMAP NOIRQ and HW A/V Sync profiles use special writing protocols. && std::find_if(flags.begin(), flags.end(), [](const auto& flag) { return flag == toString(xsd::AudioInOutFlag:: AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) || flag == toString(xsd::AudioInOutFlag:: AUDIO_OUTPUT_FLAG_HW_AV_SYNC); }) == flags.end() && !getCachedPolicyConfig() .getAttachedSinkDeviceForMixPort( std::get<PARAM_DEVICE_NAME>(std::get<PARAM_DEVICE>(cfg)), std::get<PARAM_PORT_NAME>(cfg)) .empty(); std::find_if(flags.begin(), flags.end(), [](const auto& flag) { return flag == toString(xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) || flag == toString(xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_HW_AV_SYNC); }) == flags.end(); }); return pcmParams; }(); Loading Loading @@ -677,20 +669,13 @@ static const std::vector<DeviceConfigParameter>& getInputDevicePcmOnlyConfigPara // reading h/w hotword might require Soundtrigger to be active. && std::find_if( flags.begin(), flags.end(), [](const auto& flag) { flags.begin(), flags.end(), [](const auto& flag) { return flag == toString( xsd::AudioInOutFlag:: AUDIO_INPUT_FLAG_MMAP_NOIRQ) || flag == toString(xsd::AudioInOutFlag:: AUDIO_INPUT_FLAG_HW_HOTWORD); }) == flags.end() && !getCachedPolicyConfig() .getAttachedSourceDeviceForMixPort( std::get<PARAM_DEVICE_NAME>( std::get<PARAM_DEVICE>(cfg)), std::get<PARAM_PORT_NAME>(cfg)) .empty(); }) == flags.end(); }); return pcmParams; }(); Loading audio/core/all-versions/vts/functional/7.0/Generators.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -95,11 +95,16 @@ static AudioOffloadInfo generateOffloadInfo(const AudioConfigBase& base) { std::vector<DeviceConfigParameter> generateOutputDeviceConfigParameters(bool oneProfilePerDevice) { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); const std::string moduleName = std::get<PARAM_DEVICE_NAME>(device); auto module = getCachedPolicyConfig().getModuleFromName(moduleName); if (!module || !module->getFirstMixPorts()) break; for (const auto& mixPort : module->getFirstMixPorts()->getMixPort()) { if (mixPort.getRole() != xsd::Role::source) continue; // not an output profile if (getCachedPolicyConfig() .getAttachedSinkDeviceForMixPort(moduleName, mixPort.getName()) .empty()) { continue; // no attached device } auto [flags, isOffload] = generateOutFlags(mixPort); for (const auto& profile : mixPort.getProfile()) { if (!profile.hasFormat() || !profile.hasSamplingRates() || Loading Loading @@ -223,11 +228,16 @@ const std::vector<DeviceConfigParameter>& getOutputDeviceInvalidConfigParameters std::vector<DeviceConfigParameter> generateInputDeviceConfigParameters(bool oneProfilePerDevice) { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); const std::string moduleName = std::get<PARAM_DEVICE_NAME>(device); auto module = getCachedPolicyConfig().getModuleFromName(moduleName); if (!module || !module->getFirstMixPorts()) break; for (const auto& mixPort : module->getFirstMixPorts()->getMixPort()) { if (mixPort.getRole() != xsd::Role::sink) continue; // not an input profile if (getCachedPolicyConfig() .getAttachedSourceDeviceForMixPort(moduleName, mixPort.getName()) .empty()) { continue; // no attached device } std::vector<AudioInOutFlag> flags; if (mixPort.hasFlags()) { std::transform(mixPort.getFlags().begin(), mixPort.getFlags().end(), Loading audio/core/all-versions/vts/functional/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ cc_test { data: [ "tests/apm_config_no_vx.xml", "tests/apm_config_with_vx.xml", "tests/apm_config_b_205808571_6_0.xml", ], test_config: "tests/HalAudioV6_0GeneratorTest.xml", } Loading Loading @@ -240,6 +241,7 @@ cc_test { "tests/apm_config_no_vx_7_0.xml", "tests/apm_config_with_vx_7_0.xml", "tests/apm_config_b_204314749_7_0.xml", "tests/apm_config_b_205808571_7_0.xml", ], test_config: "tests/HalAudioV7_0GeneratorTest.xml", } audio/core/all-versions/vts/functional/PolicyConfig.h +60 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,16 @@ class PolicyConfig : private PolicyConfigData, public android::AudioPolicyConfig const std::set<std::string>& getModulesWithDevicesNames() const { return mModulesWithDevicesNames; } std::string getAttachedSinkDeviceForMixPort(const std::string& moduleName, const std::string& mixPortName) const { return findAttachedDevice(getAttachedDevices(moduleName), getSinkDevicesForMixPort(moduleName, mixPortName)); } std::string getAttachedSourceDeviceForMixPort(const std::string& moduleName, const std::string& mixPortName) const { return findAttachedDevice(getAttachedDevices(moduleName), getSourceDevicesForMixPort(moduleName, mixPortName)); } bool haveInputProfilesInModule(const std::string& name) const { auto module = getModuleFromName(name); return module && !module->getInputProfiles().empty(); Loading @@ -92,6 +102,8 @@ class PolicyConfig : private PolicyConfigData, public android::AudioPolicyConfig for (const auto& module : hwModules) { if (module->getDeclaredDevices().indexOf(device) >= 0) { mModulesWithDevicesNames.insert(module->getName()); mAttachedDevicesPerModule[module->getName()].push_back( device->getTagName()); break; } } Loading @@ -100,16 +112,64 @@ class PolicyConfig : private PolicyConfigData, public android::AudioPolicyConfig for (const auto& module : hwModules) { if (module->getDeclaredDevices().indexOf(device) >= 0) { mModulesWithDevicesNames.insert(module->getName()); mAttachedDevicesPerModule[module->getName()].push_back( device->getTagName()); break; } } } } } std::string findAttachedDevice(const std::vector<std::string>& attachedDevices, const std::set<std::string>& possibleDevices) const { for (const auto& device : attachedDevices) { if (possibleDevices.count(device)) return device; } return {}; } std::vector<std::string> getAttachedDevices(const std::string& moduleName) const { if (auto iter = mAttachedDevicesPerModule.find(moduleName); iter != mAttachedDevicesPerModule.end()) { return iter->second; } return {}; } std::set<std::string> getSinkDevicesForMixPort(const std::string& moduleName, const std::string& mixPortName) const { std::set<std::string> result; auto module = getModuleFromName(moduleName); if (module != nullptr) { for (const auto& route : module->getRoutes()) { for (const auto& source : route->getSources()) { if (source->getTagName() == mixPortName) { result.insert(route->getSink()->getTagName()); } } } } return result; } std::set<std::string> getSourceDevicesForMixPort(const std::string& moduleName, const std::string& mixPortName) const { std::set<std::string> result; auto module = getModuleFromName(moduleName); if (module != nullptr) { for (const auto& route : module->getRoutes()) { if (route->getSink()->getTagName() == mixPortName) { const auto& sources = route->getSources(); std::transform(sources.begin(), sources.end(), std::inserter(result, result.end()), [](const auto& source) { return source->getTagName(); }); } } } return result; } const std::string mConfigFileName; status_t mStatus = android::NO_INIT; std::string mFilePath; sp<const android::HwModule> mPrimaryModule = nullptr; std::set<std::string> mModulesWithDevicesNames; std::map<std::string, std::vector<std::string>> mAttachedDevicesPerModule; }; Loading
audio/core/all-versions/vts/functional/6.0/Generators.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -36,9 +36,14 @@ using namespace ::android::hardware::audio::CPP_VERSION; std::vector<DeviceConfigParameter> generateOutputDeviceConfigParameters(bool oneProfilePerDevice) { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); const std::string moduleName = std::get<PARAM_DEVICE_NAME>(device); auto module = getCachedPolicyConfig().getModuleFromName(moduleName); for (const auto& ioProfile : module->getOutputProfiles()) { if (getCachedPolicyConfig() .getAttachedSinkDeviceForMixPort(moduleName, ioProfile->getName()) .empty()) { continue; // no attached device } for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); Loading Loading @@ -94,9 +99,14 @@ const std::vector<DeviceConfigParameter>& getOutputDeviceSingleConfigParameters( std::vector<DeviceConfigParameter> generateInputDeviceConfigParameters(bool oneProfilePerDevice) { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); const std::string moduleName = std::get<PARAM_DEVICE_NAME>(device); auto module = getCachedPolicyConfig().getModuleFromName(moduleName); for (const auto& ioProfile : module->getInputProfiles()) { if (getCachedPolicyConfig() .getAttachedSourceDeviceForMixPort(moduleName, ioProfile->getName()) .empty()) { continue; // no attached device } for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); Loading
audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp +6 −21 Original line number Diff line number Diff line Loading @@ -499,18 +499,10 @@ static const std::vector<DeviceConfigParameter>& getOutputDevicePcmOnlyConfigPar return xsd::isLinearPcm(std::get<PARAM_CONFIG>(cfg).base.format) // MMAP NOIRQ and HW A/V Sync profiles use special writing protocols. && std::find_if(flags.begin(), flags.end(), [](const auto& flag) { return flag == toString(xsd::AudioInOutFlag:: AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) || flag == toString(xsd::AudioInOutFlag:: AUDIO_OUTPUT_FLAG_HW_AV_SYNC); }) == flags.end() && !getCachedPolicyConfig() .getAttachedSinkDeviceForMixPort( std::get<PARAM_DEVICE_NAME>(std::get<PARAM_DEVICE>(cfg)), std::get<PARAM_PORT_NAME>(cfg)) .empty(); std::find_if(flags.begin(), flags.end(), [](const auto& flag) { return flag == toString(xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) || flag == toString(xsd::AudioInOutFlag::AUDIO_OUTPUT_FLAG_HW_AV_SYNC); }) == flags.end(); }); return pcmParams; }(); Loading Loading @@ -677,20 +669,13 @@ static const std::vector<DeviceConfigParameter>& getInputDevicePcmOnlyConfigPara // reading h/w hotword might require Soundtrigger to be active. && std::find_if( flags.begin(), flags.end(), [](const auto& flag) { flags.begin(), flags.end(), [](const auto& flag) { return flag == toString( xsd::AudioInOutFlag:: AUDIO_INPUT_FLAG_MMAP_NOIRQ) || flag == toString(xsd::AudioInOutFlag:: AUDIO_INPUT_FLAG_HW_HOTWORD); }) == flags.end() && !getCachedPolicyConfig() .getAttachedSourceDeviceForMixPort( std::get<PARAM_DEVICE_NAME>( std::get<PARAM_DEVICE>(cfg)), std::get<PARAM_PORT_NAME>(cfg)) .empty(); }) == flags.end(); }); return pcmParams; }(); Loading
audio/core/all-versions/vts/functional/7.0/Generators.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -95,11 +95,16 @@ static AudioOffloadInfo generateOffloadInfo(const AudioConfigBase& base) { std::vector<DeviceConfigParameter> generateOutputDeviceConfigParameters(bool oneProfilePerDevice) { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); const std::string moduleName = std::get<PARAM_DEVICE_NAME>(device); auto module = getCachedPolicyConfig().getModuleFromName(moduleName); if (!module || !module->getFirstMixPorts()) break; for (const auto& mixPort : module->getFirstMixPorts()->getMixPort()) { if (mixPort.getRole() != xsd::Role::source) continue; // not an output profile if (getCachedPolicyConfig() .getAttachedSinkDeviceForMixPort(moduleName, mixPort.getName()) .empty()) { continue; // no attached device } auto [flags, isOffload] = generateOutFlags(mixPort); for (const auto& profile : mixPort.getProfile()) { if (!profile.hasFormat() || !profile.hasSamplingRates() || Loading Loading @@ -223,11 +228,16 @@ const std::vector<DeviceConfigParameter>& getOutputDeviceInvalidConfigParameters std::vector<DeviceConfigParameter> generateInputDeviceConfigParameters(bool oneProfilePerDevice) { std::vector<DeviceConfigParameter> result; for (const auto& device : getDeviceParameters()) { auto module = getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device)); const std::string moduleName = std::get<PARAM_DEVICE_NAME>(device); auto module = getCachedPolicyConfig().getModuleFromName(moduleName); if (!module || !module->getFirstMixPorts()) break; for (const auto& mixPort : module->getFirstMixPorts()->getMixPort()) { if (mixPort.getRole() != xsd::Role::sink) continue; // not an input profile if (getCachedPolicyConfig() .getAttachedSourceDeviceForMixPort(moduleName, mixPort.getName()) .empty()) { continue; // no attached device } std::vector<AudioInOutFlag> flags; if (mixPort.hasFlags()) { std::transform(mixPort.getFlags().begin(), mixPort.getFlags().end(), Loading
audio/core/all-versions/vts/functional/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -211,6 +211,7 @@ cc_test { data: [ "tests/apm_config_no_vx.xml", "tests/apm_config_with_vx.xml", "tests/apm_config_b_205808571_6_0.xml", ], test_config: "tests/HalAudioV6_0GeneratorTest.xml", } Loading Loading @@ -240,6 +241,7 @@ cc_test { "tests/apm_config_no_vx_7_0.xml", "tests/apm_config_with_vx_7_0.xml", "tests/apm_config_b_204314749_7_0.xml", "tests/apm_config_b_205808571_7_0.xml", ], test_config: "tests/HalAudioV7_0GeneratorTest.xml", }
audio/core/all-versions/vts/functional/PolicyConfig.h +60 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,16 @@ class PolicyConfig : private PolicyConfigData, public android::AudioPolicyConfig const std::set<std::string>& getModulesWithDevicesNames() const { return mModulesWithDevicesNames; } std::string getAttachedSinkDeviceForMixPort(const std::string& moduleName, const std::string& mixPortName) const { return findAttachedDevice(getAttachedDevices(moduleName), getSinkDevicesForMixPort(moduleName, mixPortName)); } std::string getAttachedSourceDeviceForMixPort(const std::string& moduleName, const std::string& mixPortName) const { return findAttachedDevice(getAttachedDevices(moduleName), getSourceDevicesForMixPort(moduleName, mixPortName)); } bool haveInputProfilesInModule(const std::string& name) const { auto module = getModuleFromName(name); return module && !module->getInputProfiles().empty(); Loading @@ -92,6 +102,8 @@ class PolicyConfig : private PolicyConfigData, public android::AudioPolicyConfig for (const auto& module : hwModules) { if (module->getDeclaredDevices().indexOf(device) >= 0) { mModulesWithDevicesNames.insert(module->getName()); mAttachedDevicesPerModule[module->getName()].push_back( device->getTagName()); break; } } Loading @@ -100,16 +112,64 @@ class PolicyConfig : private PolicyConfigData, public android::AudioPolicyConfig for (const auto& module : hwModules) { if (module->getDeclaredDevices().indexOf(device) >= 0) { mModulesWithDevicesNames.insert(module->getName()); mAttachedDevicesPerModule[module->getName()].push_back( device->getTagName()); break; } } } } } std::string findAttachedDevice(const std::vector<std::string>& attachedDevices, const std::set<std::string>& possibleDevices) const { for (const auto& device : attachedDevices) { if (possibleDevices.count(device)) return device; } return {}; } std::vector<std::string> getAttachedDevices(const std::string& moduleName) const { if (auto iter = mAttachedDevicesPerModule.find(moduleName); iter != mAttachedDevicesPerModule.end()) { return iter->second; } return {}; } std::set<std::string> getSinkDevicesForMixPort(const std::string& moduleName, const std::string& mixPortName) const { std::set<std::string> result; auto module = getModuleFromName(moduleName); if (module != nullptr) { for (const auto& route : module->getRoutes()) { for (const auto& source : route->getSources()) { if (source->getTagName() == mixPortName) { result.insert(route->getSink()->getTagName()); } } } } return result; } std::set<std::string> getSourceDevicesForMixPort(const std::string& moduleName, const std::string& mixPortName) const { std::set<std::string> result; auto module = getModuleFromName(moduleName); if (module != nullptr) { for (const auto& route : module->getRoutes()) { if (route->getSink()->getTagName() == mixPortName) { const auto& sources = route->getSources(); std::transform(sources.begin(), sources.end(), std::inserter(result, result.end()), [](const auto& source) { return source->getTagName(); }); } } } return result; } const std::string mConfigFileName; status_t mStatus = android::NO_INIT; std::string mFilePath; sp<const android::HwModule> mPrimaryModule = nullptr; std::set<std::string> mModulesWithDevicesNames; std::map<std::string, std::vector<std::string>> mAttachedDevicesPerModule; };