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/core/all-versions/default/Stream.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/core/all-versions/default/Stream.cpp')
-rw-r--r-- | audio/core/all-versions/default/Stream.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/audio/core/all-versions/default/Stream.cpp b/audio/core/all-versions/default/Stream.cpp index f964cbb804..3f8efd231f 100644 --- a/audio/core/all-versions/default/Stream.cpp +++ b/audio/core/all-versions/default/Stream.cpp @@ -278,23 +278,36 @@ Return<void> Stream::getAudioProperties(getAudioProperties_cb _hidl_cb) { return Void(); } -Return<Result> Stream::setAudioProperties(const AudioConfigBase& config) { - audio_config_base_t halConfigBase = {}; - status_t status = HidlUtils::audioConfigBaseToHal(config, &halConfigBase); +Return<Result> Stream::setAudioProperties(const AudioConfigBaseOptional& config) { + audio_config_base_t halConfigBase = AUDIO_CONFIG_BASE_INITIALIZER; + bool formatSpecified, sRateSpecified, channelMaskSpecified; + status_t status = HidlUtils::audioConfigBaseOptionalToHal( + config, &halConfigBase, &formatSpecified, &sRateSpecified, &channelMaskSpecified); if (status != NO_ERROR) { return Stream::analyzeStatus("set_audio_properties", status); } - if (Result result = setParam(AudioParameter::keySamplingRate, - static_cast<int>(halConfigBase.sample_rate)); - result != Result::OK) { - return result; + if (sRateSpecified) { + if (Result result = setParam(AudioParameter::keySamplingRate, + static_cast<int>(halConfigBase.sample_rate)); + result != Result::OK) { + return result; + } + } + if (channelMaskSpecified) { + if (Result result = setParam(AudioParameter::keyChannels, + static_cast<int>(halConfigBase.channel_mask)); + result != Result::OK) { + return result; + } } - if (Result result = - setParam(AudioParameter::keyChannels, static_cast<int>(halConfigBase.channel_mask)); - result != Result::OK) { - return result; + if (formatSpecified) { + if (Result result = + setParam(AudioParameter::keyFormat, static_cast<int>(halConfigBase.format)); + result != Result::OK) { + return result; + } } - return setParam(AudioParameter::keyFormat, static_cast<int>(halConfigBase.format)); + return Result::OK; } #endif // MAJOR_VERSION <= 6 |