diff options
author | Mikhail Naganov <mnaganov@google.com> | 2021-01-27 02:16:53 +0000 |
---|---|---|
committer | Mikhail Naganov <mnaganov@google.com> | 2021-01-28 21:27:43 +0000 |
commit | ff611980f317888607389d0cb258bd86f11f2dfb (patch) | |
tree | c0c25fc7cf56730823b5cbe2b5552caac488457a /audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp | |
parent | 31f2eb37915bf81117a77fc48af01ec7bdb4e381 (diff) |
audio: Update common types to better match legacy structs
HAL V7 types were updated to better match data structure
definitions from the legacy HAL:
- Added 'AudioConfigBaseOptional' struct to match
legacy structs that have 'mask' field to specify
initialized fields.
- All fields in 'AudioConfigBase' made mandatory.
- Removed 'EffectConfigParameters' in favor of
'AudioConfigBaseOptional' and safe_unions.
- Added missing enum string values to ensure that round-trip
conversions from the legacy HAL to HIDL and back to legacy
preserve enum values.
Bug: 142480271
Test: atest android.hardware.audio.common@7.0-util_tests
Test: atest VtsHalAudioV6_0TargetTest
Test: atest VtsHalAudioV7_0TargetTest
Test: atest VtsHalAudioEffectV7_0TargetTest
Change-Id: If02a81b3f6790a8eb315fa57123141aad2419132
Diffstat (limited to 'audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp')
-rw-r--r-- | audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp index 35ff8693a4..15a2fd928c 100644 --- a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp +++ b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp @@ -264,8 +264,10 @@ void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) { *channelCount = audio_channel_count_from_out_mask( static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)); #else + ASSERT_EQ(AudioConfigBaseOptional::ChannelMask::hidl_discriminator::value, + currentConfig.outputCfg.base.channelMask.getDiscriminator()); *channelCount = android::audio::policy::configuration::V7_0::getChannelCount( - currentConfig.outputCfg.base.channelMask); + currentConfig.outputCfg.base.channelMask.value()); ASSERT_NE(*channelCount, 0); #endif } @@ -315,10 +317,10 @@ TEST_P(AudioEffectHidlTest, GetSetConfig) { std::vector<EffectBufferConfig> generateInvalidConfigs(const EffectBufferConfig& src) { std::vector<EffectBufferConfig> result; EffectBufferConfig invalidFormat = src; - invalidFormat.base.format = "random_string"; + invalidFormat.base.format.value("random_string"); result.push_back(std::move(invalidFormat)); EffectBufferConfig invalidChannelMask = src; - invalidChannelMask.base.channelMask = "random_string"; + invalidChannelMask.base.channelMask.value("random_string"); result.push_back(std::move(invalidChannelMask)); return result; } @@ -395,17 +397,22 @@ inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) { rhs.data.handle() == nullptr; } +#if MAJOR_VERSION <= 6 inline bool operator==(const EffectBufferConfig& lhs, const EffectBufferConfig& rhs) { return lhs.buffer == rhs.buffer && -#if MAJOR_VERSION <= 6 lhs.samplingRateHz == rhs.samplingRateHz && lhs.channels == rhs.channels && lhs.format == rhs.format && -#else - lhs.base.sampleRateHz == rhs.base.sampleRateHz && - lhs.base.channelMask == rhs.base.channelMask && lhs.base.format == rhs.base.format && -#endif lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask; } +#else +inline bool operator==(const EffectBufferConfig& lhs, const EffectBufferConfig& rhs) { + return lhs.buffer.getDiscriminator() == rhs.buffer.getDiscriminator() && + (lhs.buffer.getDiscriminator() == + EffectBufferConfig::OptionalBuffer::hidl_discriminator::unspecified || + lhs.buffer.buf() == rhs.buffer.buf()) && + lhs.base == rhs.base && lhs.accessMode == rhs.accessMode; +} +#endif // MAJOR_VERSION <= 6 inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) { return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg; |