summaryrefslogtreecommitdiff
path: root/audio/common/all-versions/default/tests/hidlutils_tests.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/tests/hidlutils_tests.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/tests/hidlutils_tests.cpp')
-rw-r--r--audio/common/all-versions/default/tests/hidlutils_tests.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/audio/common/all-versions/default/tests/hidlutils_tests.cpp b/audio/common/all-versions/default/tests/hidlutils_tests.cpp
index 40fc5c81c6..99d2e7246e 100644
--- a/audio/common/all-versions/default/tests/hidlutils_tests.cpp
+++ b/audio/common/all-versions/default/tests/hidlutils_tests.cpp
@@ -44,8 +44,8 @@ static constexpr audio_gain_mode_t kInvalidHalGainMode =
static_cast<audio_gain_mode_t>(0xFFFFFFFFU);
// AUDIO_SOURCE_INVALID is framework-only.
static constexpr audio_source_t kInvalidHalSource = static_cast<audio_source_t>(-1);
-static constexpr audio_stream_type_t kInvalidHalStreamType =
- static_cast<audio_stream_type_t>(0xFFFFFFFFU);
+// AUDIO_STREAM_DEFAULT is framework-only
+static constexpr audio_stream_type_t kInvalidHalStreamType = static_cast<audio_stream_type_t>(-2);
static constexpr audio_usage_t kInvalidHalUsage = static_cast<audio_usage_t>(0xFFFFFFFFU);
TEST(HidlUtils, ConvertInvalidChannelMask) {
@@ -660,10 +660,18 @@ TEST(HidlUtils, ConvertInvalidStreamType) {
AudioStreamType invalid;
EXPECT_EQ(BAD_VALUE, HidlUtils::audioStreamTypeFromHal(kInvalidHalStreamType, &invalid));
audio_stream_type_t halInvalid;
- EXPECT_EQ(BAD_VALUE, HidlUtils::audioStreamTypeToHal("", &halInvalid));
EXPECT_EQ(BAD_VALUE, HidlUtils::audioStreamTypeToHal("random string", &halInvalid));
}
+TEST(HidlUtils, ConvertDefaultStreamType) {
+ AudioStreamType streamDefault = "";
+ audio_stream_type_t halStreamDefault;
+ EXPECT_EQ(NO_ERROR, HidlUtils::audioStreamTypeToHal(streamDefault, &halStreamDefault));
+ AudioStreamType streamDefaultBack;
+ EXPECT_EQ(NO_ERROR, HidlUtils::audioStreamTypeFromHal(halStreamDefault, &streamDefaultBack));
+ EXPECT_EQ(streamDefault, streamDefaultBack);
+}
+
TEST(HidlUtils, ConvertStreamType) {
for (const auto enumVal : xsdc_enum_range<xsd::AudioStreamType>{}) {
const AudioStreamType streamType = toString(enumVal);