diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-01-30 00:08:00 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-01-30 00:08:00 +0000 |
commit | 418ad80fee08d05896081b9cd0daf95bc1a289c6 (patch) | |
tree | 6def95f5e636d5799f17441d713a052c44d70d98 /audio/core/all-versions/default/Stream.cpp | |
parent | c33b0ae83c94460abf80908c6a54666ba6a7b5fc (diff) | |
parent | 39059ed17f8fef43fee286cc0eacbb910ee2b772 (diff) |
Merge "audio: Update common types to better match legacy structs" am: 39059ed17f
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1562143
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: I69827fcf8c3f9b0414edb57406c696da3688cee9
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 |