summaryrefslogtreecommitdiffstats
path: root/audio/2.0
diff options
context:
space:
mode:
authorKevin Rocard <krocard@google.com>2017-12-01 22:06:14 -0800
committerKevin Rocard <krocard@google.com>2017-12-05 15:14:17 -0800
commit02025847dea97d50014d1fd23060c4d62472e020 (patch)
treefb0ab6bf96dd460044e14f9c5ad82b6a0c9845a9 /audio/2.0
parent1a5c25dd953d8f4a048fe410550c3c3dc4be4acc (diff)
downloadplatform_hardware_interfaces-02025847dea97d50014d1fd23060c4d62472e020.tar.gz
platform_hardware_interfaces-02025847dea97d50014d1fd23060c4d62472e020.tar.bz2
platform_hardware_interfaces-02025847dea97d50014d1fd23060c4d62472e020.zip
Audio VTS: HAL can support more than the native sampling rates
getSupportedSampleRate should return the native sampling rates, (IE. the sampling rates that can be played without resampling) but other sampling rates can be supported by the HAL. The test was too strict as it was failing if HALs were supporting more sample rates than there native (optimized) ones. For example, a HAL might have its best performance (no resampling) on 48kHz but still support 16kHz through resampling. Note: getSupportedSampleRate might be renamed to getNativeSampleRate in the next major HAL revision to avoid ambiguity. Test: vts-tradefed run commandAndExit vts --module VtsHalAudioV2_0Target -t CheckConfig.audioPolicyConfigurationValidation Bug: 69811500 Change-Id: I1ec1ce422bc5039637463c6641060508f4ee892b Signed-off-by: Kevin Rocard <krocard@google.com>
Diffstat (limited to 'audio/2.0')
-rw-r--r--audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index 3ee44f33ca..ec9755d441 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -768,11 +768,12 @@ TEST_IO_STREAM(GetBufferSize,
ASSERT_GE(extract(stream->getBufferSize()),
extract(stream->getFrameSize())));
-template <class Property, class CapabilityGetter, class Getter, class Setter>
+template <class Property, class CapabilityGetter>
static void testCapabilityGetter(const string& name, IStream* stream,
- Property currentValue,
CapabilityGetter capablityGetter,
- Getter getter, Setter setter) {
+ Return<Property> (IStream::*getter)(),
+ Return<Result> (IStream::*setter)(Property),
+ bool currentMustBeSupported = true) {
hidl_vec<Property> capabilities;
ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities)));
if (capabilities.size() == 0) {
@@ -783,12 +784,14 @@ static void testCapabilityGetter(const string& name, IStream* stream,
doc::partialTest(name + " is not supported");
return;
};
- // TODO: This code has never been tested on a hal that supports
- // getSupportedSampleRates
- EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
- capabilities.end())
- << "current " << name << " is not in the list of the supported ones "
- << toString(capabilities);
+
+ if (currentMustBeSupported) {
+ Property currentValue = extract((stream->*getter)());
+ EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
+ capabilities.end())
+ << "current " << name << " is not in the list of the supported ones "
+ << toString(capabilities);
+ }
// Check that all declared supported values are indeed supported
for (auto capability : capabilities) {
@@ -800,15 +803,17 @@ static void testCapabilityGetter(const string& name, IStream* stream,
TEST_IO_STREAM(SupportedSampleRate,
"Check that the stream sample rate is declared as supported",
testCapabilityGetter("getSupportedSampleRate", stream.get(),
- extract(stream->getSampleRate()),
&IStream::getSupportedSampleRates,
&IStream::getSampleRate,
- &IStream::setSampleRate))
+ &IStream::setSampleRate,
+ // getSupportedSampleRate returns the native sampling rates,
+ // (the sampling rates that can be played without resampling)
+ // but other sampling rates can be supported by the HAL.
+ false))
TEST_IO_STREAM(SupportedChannelMask,
"Check that the stream channel mask is declared as supported",
testCapabilityGetter("getSupportedChannelMask", stream.get(),
- extract(stream->getChannelMask()),
&IStream::getSupportedChannelMasks,
&IStream::getChannelMask,
&IStream::setChannelMask))
@@ -816,7 +821,6 @@ TEST_IO_STREAM(SupportedChannelMask,
TEST_IO_STREAM(SupportedFormat,
"Check that the stream format is declared as supported",
testCapabilityGetter("getSupportedFormat", stream.get(),
- extract(stream->getFormat()),
&IStream::getSupportedFormats,
&IStream::getFormat, &IStream::setFormat))