summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Rocard2017-12-02 00:06:14 -0600
committerKevin Rocard2017-12-05 17:14:17 -0600
commit02025847dea97d50014d1fd23060c4d62472e020 (patch)
treefb0ab6bf96dd460044e14f9c5ad82b6a0c9845a9
parent1a5c25dd953d8f4a048fe410550c3c3dc4be4acc (diff)
downloadplatform-hardware-interfaces-02025847dea97d50014d1fd23060c4d62472e020.tar.gz
platform-hardware-interfaces-02025847dea97d50014d1fd23060c4d62472e020.tar.xz
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>
-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 3ee44f33..ec9755d4 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,
768 ASSERT_GE(extract(stream->getBufferSize()), 768 ASSERT_GE(extract(stream->getBufferSize()),
769 extract(stream->getFrameSize()))); 769 extract(stream->getFrameSize())));
770 770
771template <class Property, class CapabilityGetter, class Getter, class Setter> 771template <class Property, class CapabilityGetter>
772static void testCapabilityGetter(const string& name, IStream* stream, 772static void testCapabilityGetter(const string& name, IStream* stream,
773 Property currentValue,
774 CapabilityGetter capablityGetter, 773 CapabilityGetter capablityGetter,
775 Getter getter, Setter setter) { 774 Return<Property> (IStream::*getter)(),
775 Return<Result> (IStream::*setter)(Property),
776 bool currentMustBeSupported = true) {
776 hidl_vec<Property> capabilities; 777 hidl_vec<Property> capabilities;
777 ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities))); 778 ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities)));
778 if (capabilities.size() == 0) { 779 if (capabilities.size() == 0) {
@@ -783,12 +784,14 @@ static void testCapabilityGetter(const string& name, IStream* stream,
783 doc::partialTest(name + " is not supported"); 784 doc::partialTest(name + " is not supported");
784 return; 785 return;
785 }; 786 };
786 // TODO: This code has never been tested on a hal that supports 787
787 // getSupportedSampleRates 788 if (currentMustBeSupported) {
788 EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue), 789 Property currentValue = extract((stream->*getter)());
789 capabilities.end()) 790 EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue),
790 << "current " << name << " is not in the list of the supported ones " 791 capabilities.end())
791 << toString(capabilities); 792 << "current " << name << " is not in the list of the supported ones "
793 << toString(capabilities);
794 }
792 795
793 // Check that all declared supported values are indeed supported 796 // Check that all declared supported values are indeed supported
794 for (auto capability : capabilities) { 797 for (auto capability : capabilities) {
@@ -800,15 +803,17 @@ static void testCapabilityGetter(const string& name, IStream* stream,
800TEST_IO_STREAM(SupportedSampleRate, 803TEST_IO_STREAM(SupportedSampleRate,
801 "Check that the stream sample rate is declared as supported", 804 "Check that the stream sample rate is declared as supported",
802 testCapabilityGetter("getSupportedSampleRate", stream.get(), 805 testCapabilityGetter("getSupportedSampleRate", stream.get(),
803 extract(stream->getSampleRate()),
804 &IStream::getSupportedSampleRates, 806 &IStream::getSupportedSampleRates,
805 &IStream::getSampleRate, 807 &IStream::getSampleRate,
806 &IStream::setSampleRate)) 808 &IStream::setSampleRate,
809 // getSupportedSampleRate returns the native sampling rates,
810 // (the sampling rates that can be played without resampling)
811 // but other sampling rates can be supported by the HAL.
812 false))
807 813
808TEST_IO_STREAM(SupportedChannelMask, 814TEST_IO_STREAM(SupportedChannelMask,
809 "Check that the stream channel mask is declared as supported", 815 "Check that the stream channel mask is declared as supported",
810 testCapabilityGetter("getSupportedChannelMask", stream.get(), 816 testCapabilityGetter("getSupportedChannelMask", stream.get(),
811 extract(stream->getChannelMask()),
812 &IStream::getSupportedChannelMasks, 817 &IStream::getSupportedChannelMasks,
813 &IStream::getChannelMask, 818 &IStream::getChannelMask,
814 &IStream::setChannelMask)) 819 &IStream::setChannelMask))
@@ -816,7 +821,6 @@ TEST_IO_STREAM(SupportedChannelMask,
816TEST_IO_STREAM(SupportedFormat, 821TEST_IO_STREAM(SupportedFormat,
817 "Check that the stream format is declared as supported", 822 "Check that the stream format is declared as supported",
818 testCapabilityGetter("getSupportedFormat", stream.get(), 823 testCapabilityGetter("getSupportedFormat", stream.get(),
819 extract(stream->getFormat()),
820 &IStream::getSupportedFormats, 824 &IStream::getSupportedFormats,
821 &IStream::getFormat, &IStream::setFormat)) 825 &IStream::getFormat, &IStream::setFormat))
822 826