summaryrefslogtreecommitdiff
path: root/audio/common/all-versions/default/7.0/HidlUtils.cpp
diff options
context:
space:
mode:
authorMikhail Naganov <mnaganov@google.com>2021-02-10 04:20:04 +0000
committerMikhail Naganov <mnaganov@google.com>2021-02-09 20:41:52 -0800
commit5fd0c77caf42f1553c99d15da3a7c131b83a74d1 (patch)
tree28021d93c29c6abcfb510aa60aa27c031a82ba4e /audio/common/all-versions/default/7.0/HidlUtils.cpp
parent7e734892c953c7f5dd52c8aca3d56f1b23607223 (diff)
audio: Allow specifying "default" stream type in V7
Despite that AUDIO_STREAM_DEFAULT value of audio_stream_type_t should only used by the framework, it can still end up being passed to the HAL in port configs and offload info structures. This happens in the cases when the stream type is not actually used by the HAL. It seems natural to use an empty string as the value of AudioStreamType field in this case. Bug: 179743630 Test: atest android.hardware.audio.common@7.0-util_tests Test: make a telephone call on a device with HAL V7 Change-Id: Ia330031fca9d081627746b4f6074162835c4c54b
Diffstat (limited to 'audio/common/all-versions/default/7.0/HidlUtils.cpp')
-rw-r--r--audio/common/all-versions/default/7.0/HidlUtils.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/audio/common/all-versions/default/7.0/HidlUtils.cpp b/audio/common/all-versions/default/7.0/HidlUtils.cpp
index bb3a5968b5..2949fac293 100644
--- a/audio/common/all-versions/default/7.0/HidlUtils.cpp
+++ b/audio/common/all-versions/default/7.0/HidlUtils.cpp
@@ -335,25 +335,35 @@ status_t HidlUtils::audioSourceToHal(const AudioSource& source, audio_source_t*
return BAD_VALUE;
}
+// The "default" value of audio_stream_type_t is represented by an empty string.
status_t HidlUtils::audioStreamTypeFromHal(audio_stream_type_t halStreamType,
AudioStreamType* streamType) {
- *streamType = audio_stream_type_to_string(halStreamType);
- if (!streamType->empty() && !xsd::isUnknownAudioStreamType(*streamType)) {
+ if (halStreamType != AUDIO_STREAM_DEFAULT) {
+ *streamType = audio_stream_type_to_string(halStreamType);
+ if (!streamType->empty() && !xsd::isUnknownAudioStreamType(*streamType)) {
+ return NO_ERROR;
+ }
+ ALOGE("Unknown audio stream type value 0x%X", halStreamType);
+ return BAD_VALUE;
+ } else {
+ *streamType = "";
return NO_ERROR;
}
- ALOGE("Unknown audio stream type value 0x%X", halStreamType);
- return BAD_VALUE;
}
status_t HidlUtils::audioStreamTypeToHal(const AudioStreamType& streamType,
audio_stream_type_t* halStreamType) {
- if (!xsd::isUnknownAudioStreamType(streamType) &&
- audio_stream_type_from_string(streamType.c_str(), halStreamType)) {
+ if (!streamType.empty()) {
+ if (!xsd::isUnknownAudioStreamType(streamType) &&
+ audio_stream_type_from_string(streamType.c_str(), halStreamType)) {
+ return NO_ERROR;
+ }
+ ALOGE("Unknown audio stream type \"%s\"", streamType.c_str());
+ return BAD_VALUE;
+ } else {
+ *halStreamType = AUDIO_STREAM_DEFAULT;
return NO_ERROR;
}
- ALOGE("Unknown audio stream type \"%s\"", streamType.c_str());
- *halStreamType = AUDIO_STREAM_DEFAULT;
- return BAD_VALUE;
}
status_t HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, bool isInput,