Loading audio/core/all-versions/default/TEST_MAPPING +6 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,12 @@ "presubmit": [ { "name": "android.hardware.audio@7.0-util_tests" }, { "name": "HalAudioV6_0GeneratorTest" }, { "name": "HalAudioV7_0GeneratorTest" } ] } audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp +0 −99 Original line number Diff line number Diff line Loading @@ -17,105 +17,6 @@ // pull in all the <= 5.0 tests #include "5.0/AudioPrimaryHidlHalTest.cpp" #if MAJOR_VERSION <= 6 static 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)); for (const auto& ioProfile : module->getOutputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); auto configs = ConfigHelper::combineAudioConfig( std::vector<audio_channel_mask_t>(channels.begin(), channels.end()), std::vector<uint32_t>(sampleRates.begin(), sampleRates.end()), profile->getFormat()); auto flags = ioProfile->getFlags(); for (auto& config : configs) { // Some combinations of flags declared in the config file require special // treatment. if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { config.offloadInfo.sampleRateHz = config.sampleRateHz; config.offloadInfo.channelMask = config.channelMask; config.offloadInfo.format = config.format; config.offloadInfo.streamType = AudioStreamType::MUSIC; config.offloadInfo.bitRatePerSecond = 320; config.offloadInfo.durationMicroseconds = -1; config.offloadInfo.bitWidth = 16; config.offloadInfo.bufferSize = 256; // arbitrary value config.offloadInfo.usage = AudioUsage::MEDIA; result.emplace_back(device, config, AudioOutputFlag(AudioOutputFlag::COMPRESS_OFFLOAD | AudioOutputFlag::DIRECT)); } else { if (flags & AUDIO_OUTPUT_FLAG_PRIMARY) { // ignore the flag flags &= ~AUDIO_OUTPUT_FLAG_PRIMARY; } result.emplace_back(device, config, AudioOutputFlag(flags)); } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } } return result; } const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateOutputDeviceConfigParameters(false); return parameters; } const std::vector<DeviceConfigParameter>& getOutputDeviceSingleConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateOutputDeviceConfigParameters(true); return parameters; } static 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)); for (const auto& ioProfile : module->getInputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); auto configs = ConfigHelper::combineAudioConfig( std::vector<audio_channel_mask_t>(channels.begin(), channels.end()), std::vector<uint32_t>(sampleRates.begin(), sampleRates.end()), profile->getFormat()); for (const auto& config : configs) { result.emplace_back(device, config, AudioInputFlag(ioProfile->getFlags())); if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } } return result; } const std::vector<DeviceConfigParameter>& getInputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateInputDeviceConfigParameters(false); return parameters; } const std::vector<DeviceConfigParameter>& getInputDeviceSingleConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateInputDeviceConfigParameters(true); return parameters; } #endif // MAJOR_VERSION <= 6 class SingleConfigOutputStreamTest : public OutputStreamTest {}; TEST_P(SingleConfigOutputStreamTest, CloseDeviceWithOpenedOutputStreams) { doc::test("Verify that a device can't be closed if there are output streams opened"); Loading audio/core/all-versions/vts/functional/6.0/Generators.cpp 0 → 100644 +129 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <android-base/macros.h> #include "6.0/Generators.h" #include "ConfigHelper.h" #include "PolicyConfig.h" // clang-format off #include PATH(android/hardware/audio/FILE_VERSION/types.h) #include PATH(android/hardware/audio/common/FILE_VERSION/types.h) // clang-format on // Forward declaration for functions that are substituted // in generator unit tests. const PolicyConfig& getCachedPolicyConfig(); const std::vector<DeviceParameter>& getDeviceParameters(); using namespace ::android::hardware::audio::common::CPP_VERSION; 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)); for (const auto& ioProfile : module->getOutputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); auto configs = ConfigHelper::combineAudioConfig( std::vector<audio_channel_mask_t>(channels.begin(), channels.end()), std::vector<uint32_t>(sampleRates.begin(), sampleRates.end()), profile->getFormat()); auto flags = ioProfile->getFlags(); for (auto& config : configs) { // Some combinations of flags declared in the config file require special // treatment. if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { config.offloadInfo.sampleRateHz = config.sampleRateHz; config.offloadInfo.channelMask = config.channelMask; config.offloadInfo.format = config.format; config.offloadInfo.streamType = AudioStreamType::MUSIC; config.offloadInfo.bitRatePerSecond = 320; config.offloadInfo.durationMicroseconds = -1; config.offloadInfo.bitWidth = 16; config.offloadInfo.bufferSize = 256; // arbitrary value config.offloadInfo.usage = AudioUsage::MEDIA; result.emplace_back(device, config, AudioOutputFlag(AudioOutputFlag::COMPRESS_OFFLOAD | AudioOutputFlag::DIRECT)); } else { if (flags & AUDIO_OUTPUT_FLAG_PRIMARY) { // ignore the flag flags &= ~AUDIO_OUTPUT_FLAG_PRIMARY; } result.emplace_back(device, config, AudioOutputFlag(flags)); } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } } return result; } const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateOutputDeviceConfigParameters(false); return parameters; } const std::vector<DeviceConfigParameter>& getOutputDeviceSingleConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateOutputDeviceConfigParameters(true); return parameters; } 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)); for (const auto& ioProfile : module->getInputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); auto configs = ConfigHelper::combineAudioConfig( std::vector<audio_channel_mask_t>(channels.begin(), channels.end()), std::vector<uint32_t>(sampleRates.begin(), sampleRates.end()), profile->getFormat()); for (const auto& config : configs) { result.emplace_back(device, config, AudioInputFlag(ioProfile->getFlags())); if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } } return result; } const std::vector<DeviceConfigParameter>& getInputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateInputDeviceConfigParameters(false); return parameters; } const std::vector<DeviceConfigParameter>& getInputDeviceSingleConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateInputDeviceConfigParameters(true); return parameters; } audio/core/all-versions/vts/functional/6.0/Generators.h 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <vector> #include "AudioTestDefinitions.h" const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters(); const std::vector<DeviceConfigParameter>& getOutputDeviceSingleConfigParameters(); const std::vector<DeviceConfigParameter>& getInputDeviceConfigParameters(); const std::vector<DeviceConfigParameter>& getInputDeviceSingleConfigParameters(); // For unit tests std::vector<DeviceConfigParameter> generateOutputDeviceConfigParameters(bool oneProfilePerDevice); std::vector<DeviceConfigParameter> generateInputDeviceConfigParameters(bool oneProfilePerDevice); audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp +2 −268 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
audio/core/all-versions/default/TEST_MAPPING +6 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,12 @@ "presubmit": [ { "name": "android.hardware.audio@7.0-util_tests" }, { "name": "HalAudioV6_0GeneratorTest" }, { "name": "HalAudioV7_0GeneratorTest" } ] }
audio/core/all-versions/vts/functional/6.0/AudioPrimaryHidlHalTest.cpp +0 −99 Original line number Diff line number Diff line Loading @@ -17,105 +17,6 @@ // pull in all the <= 5.0 tests #include "5.0/AudioPrimaryHidlHalTest.cpp" #if MAJOR_VERSION <= 6 static 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)); for (const auto& ioProfile : module->getOutputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); auto configs = ConfigHelper::combineAudioConfig( std::vector<audio_channel_mask_t>(channels.begin(), channels.end()), std::vector<uint32_t>(sampleRates.begin(), sampleRates.end()), profile->getFormat()); auto flags = ioProfile->getFlags(); for (auto& config : configs) { // Some combinations of flags declared in the config file require special // treatment. if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { config.offloadInfo.sampleRateHz = config.sampleRateHz; config.offloadInfo.channelMask = config.channelMask; config.offloadInfo.format = config.format; config.offloadInfo.streamType = AudioStreamType::MUSIC; config.offloadInfo.bitRatePerSecond = 320; config.offloadInfo.durationMicroseconds = -1; config.offloadInfo.bitWidth = 16; config.offloadInfo.bufferSize = 256; // arbitrary value config.offloadInfo.usage = AudioUsage::MEDIA; result.emplace_back(device, config, AudioOutputFlag(AudioOutputFlag::COMPRESS_OFFLOAD | AudioOutputFlag::DIRECT)); } else { if (flags & AUDIO_OUTPUT_FLAG_PRIMARY) { // ignore the flag flags &= ~AUDIO_OUTPUT_FLAG_PRIMARY; } result.emplace_back(device, config, AudioOutputFlag(flags)); } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } } return result; } const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateOutputDeviceConfigParameters(false); return parameters; } const std::vector<DeviceConfigParameter>& getOutputDeviceSingleConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateOutputDeviceConfigParameters(true); return parameters; } static 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)); for (const auto& ioProfile : module->getInputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); auto configs = ConfigHelper::combineAudioConfig( std::vector<audio_channel_mask_t>(channels.begin(), channels.end()), std::vector<uint32_t>(sampleRates.begin(), sampleRates.end()), profile->getFormat()); for (const auto& config : configs) { result.emplace_back(device, config, AudioInputFlag(ioProfile->getFlags())); if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } } return result; } const std::vector<DeviceConfigParameter>& getInputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateInputDeviceConfigParameters(false); return parameters; } const std::vector<DeviceConfigParameter>& getInputDeviceSingleConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateInputDeviceConfigParameters(true); return parameters; } #endif // MAJOR_VERSION <= 6 class SingleConfigOutputStreamTest : public OutputStreamTest {}; TEST_P(SingleConfigOutputStreamTest, CloseDeviceWithOpenedOutputStreams) { doc::test("Verify that a device can't be closed if there are output streams opened"); Loading
audio/core/all-versions/vts/functional/6.0/Generators.cpp 0 → 100644 +129 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <android-base/macros.h> #include "6.0/Generators.h" #include "ConfigHelper.h" #include "PolicyConfig.h" // clang-format off #include PATH(android/hardware/audio/FILE_VERSION/types.h) #include PATH(android/hardware/audio/common/FILE_VERSION/types.h) // clang-format on // Forward declaration for functions that are substituted // in generator unit tests. const PolicyConfig& getCachedPolicyConfig(); const std::vector<DeviceParameter>& getDeviceParameters(); using namespace ::android::hardware::audio::common::CPP_VERSION; 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)); for (const auto& ioProfile : module->getOutputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); auto configs = ConfigHelper::combineAudioConfig( std::vector<audio_channel_mask_t>(channels.begin(), channels.end()), std::vector<uint32_t>(sampleRates.begin(), sampleRates.end()), profile->getFormat()); auto flags = ioProfile->getFlags(); for (auto& config : configs) { // Some combinations of flags declared in the config file require special // treatment. if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) { config.offloadInfo.sampleRateHz = config.sampleRateHz; config.offloadInfo.channelMask = config.channelMask; config.offloadInfo.format = config.format; config.offloadInfo.streamType = AudioStreamType::MUSIC; config.offloadInfo.bitRatePerSecond = 320; config.offloadInfo.durationMicroseconds = -1; config.offloadInfo.bitWidth = 16; config.offloadInfo.bufferSize = 256; // arbitrary value config.offloadInfo.usage = AudioUsage::MEDIA; result.emplace_back(device, config, AudioOutputFlag(AudioOutputFlag::COMPRESS_OFFLOAD | AudioOutputFlag::DIRECT)); } else { if (flags & AUDIO_OUTPUT_FLAG_PRIMARY) { // ignore the flag flags &= ~AUDIO_OUTPUT_FLAG_PRIMARY; } result.emplace_back(device, config, AudioOutputFlag(flags)); } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } } return result; } const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateOutputDeviceConfigParameters(false); return parameters; } const std::vector<DeviceConfigParameter>& getOutputDeviceSingleConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateOutputDeviceConfigParameters(true); return parameters; } 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)); for (const auto& ioProfile : module->getInputProfiles()) { for (const auto& profile : ioProfile->getAudioProfiles()) { const auto& channels = profile->getChannels(); const auto& sampleRates = profile->getSampleRates(); auto configs = ConfigHelper::combineAudioConfig( std::vector<audio_channel_mask_t>(channels.begin(), channels.end()), std::vector<uint32_t>(sampleRates.begin(), sampleRates.end()), profile->getFormat()); for (const auto& config : configs) { result.emplace_back(device, config, AudioInputFlag(ioProfile->getFlags())); if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } if (oneProfilePerDevice) break; } } return result; } const std::vector<DeviceConfigParameter>& getInputDeviceConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateInputDeviceConfigParameters(false); return parameters; } const std::vector<DeviceConfigParameter>& getInputDeviceSingleConfigParameters() { static std::vector<DeviceConfigParameter> parameters = generateInputDeviceConfigParameters(true); return parameters; }
audio/core/all-versions/vts/functional/6.0/Generators.h 0 → 100644 +30 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <vector> #include "AudioTestDefinitions.h" const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters(); const std::vector<DeviceConfigParameter>& getOutputDeviceSingleConfigParameters(); const std::vector<DeviceConfigParameter>& getInputDeviceConfigParameters(); const std::vector<DeviceConfigParameter>& getInputDeviceSingleConfigParameters(); // For unit tests std::vector<DeviceConfigParameter> generateOutputDeviceConfigParameters(bool oneProfilePerDevice); std::vector<DeviceConfigParameter> generateInputDeviceConfigParameters(bool oneProfilePerDevice);
audio/core/all-versions/vts/functional/7.0/AudioPrimaryHidlHalTest.cpp +2 −268 File changed.Preview size limit exceeded, changes collapsed. Show changes