From 797b5b45fc20510836f14d27a507825275ab084c Mon Sep 17 00:00:00 2001 From: jiabin Date: Wed, 31 Jul 2019 12:54:19 -0700 Subject: [PATCH 1/2] Add libaudiofoundation. Some classes, e.g. AudioGain, in libaudiofoundation, which are used by libaudiopolicycomponent, will require libaudiofoundation as a shared library to avoid link error when building. Bug: 135621476 Test: make Change-Id: I8732bdab37d8afd866fe03a74db3dc564fea1ad2 Merged-In: I8732bdab37d8afd866fe03a74db3dc564fea1ad2 --- audio/core/all-versions/vts/functional/Android.bp | 1 + 1 file changed, 1 insertion(+) diff --git a/audio/core/all-versions/vts/functional/Android.bp b/audio/core/all-versions/vts/functional/Android.bp index 3286ecb0a3..73af7f471e 100644 --- a/audio/core/all-versions/vts/functional/Android.bp +++ b/audio/core/all-versions/vts/functional/Android.bp @@ -24,6 +24,7 @@ cc_defaults { "libxml2", ], shared_libs: [ + "libaudiofoundation", "libfmq", ], header_libs: [ From 5da42a3e3a7ef54cb8ada5d62ca3c999afbd9492 Mon Sep 17 00:00:00 2001 From: jiabin Date: Wed, 24 Jul 2019 17:33:02 -0700 Subject: [PATCH 2/2] Use audio containers from libaudiofoundation. It is suggested to do so according to Vector.h and SortedVector.h. At framework side, there are audio containers such as FormatVector, ChannelMaskSet, SampleRateSet to replace the usage of Vector SortedVector for audio stuff. In default hal implementation, we can use these audio containers to replace Vector and SortedVector. Bug: 135621476 Test: play/record audio Change-Id: I4d985327fb76cd06afe241860d8b592abcbfe4f2 Merged-In: I4d985327fb76cd06afe241860d8b592abcbfe4f2 --- audio/core/all-versions/default/Android.bp | 1 + audio/core/all-versions/default/Stream.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/audio/core/all-versions/default/Android.bp b/audio/core/all-versions/default/Android.bp index 007ad8594c..6f18d1d67b 100644 --- a/audio/core/all-versions/default/Android.bp +++ b/audio/core/all-versions/default/Android.bp @@ -19,6 +19,7 @@ cc_defaults { export_include_dirs: ["include"], shared_libs: [ + "libaudiofoundation", "libbase", "libcutils", "libfmq", diff --git a/audio/core/all-versions/default/Stream.cpp b/audio/core/all-versions/default/Stream.cpp index 5f24a5d781..74e59450f0 100644 --- a/audio/core/all-versions/default/Stream.cpp +++ b/audio/core/all-versions/default/Stream.cpp @@ -26,9 +26,8 @@ #include #include #include +#include #include -#include -#include namespace android { namespace hardware { @@ -100,11 +99,11 @@ Return Stream::getSupportedSampleRates(AudioFormat format, Result result = getParam(AudioParameter::keyStreamSupportedSamplingRates, &halListValue, context); hidl_vec sampleRates; - SortedVector halSampleRates; + SampleRateSet halSampleRates; if (result == Result::OK) { halSampleRates = samplingRatesFromString(halListValue.string(), AudioParameter::valueListSeparator); - sampleRates.setToExternal(halSampleRates.editArray(), halSampleRates.size()); + sampleRates = hidl_vec(halSampleRates.begin(), halSampleRates.end()); // Legacy get_parameter does not return a status_t, thus can not advertise of failure. // Note that this method must succeed (non empty list) if the format is supported. if (sampleRates.size() == 0) { @@ -126,13 +125,14 @@ Return Stream::getSupportedChannelMasks(AudioFormat format, String8 halListValue; Result result = getParam(AudioParameter::keyStreamSupportedChannels, &halListValue, context); hidl_vec channelMasks; - SortedVector halChannelMasks; + ChannelMaskSet halChannelMasks; if (result == Result::OK) { halChannelMasks = channelMasksFromString(halListValue.string(), AudioParameter::valueListSeparator); channelMasks.resize(halChannelMasks.size()); - for (size_t i = 0; i < halChannelMasks.size(); ++i) { - channelMasks[i] = AudioChannelBitfield(halChannelMasks[i]); + size_t i = 0; + for (auto channelMask : halChannelMasks) { + channelMasks[i++] = AudioChannelBitfield(channelMask); } // Legacy get_parameter does not return a status_t, thus can not advertise of failure. // Note that this method must succeed (non empty list) if the format is supported. @@ -168,7 +168,7 @@ Return Stream::getSupportedFormats(getSupportedFormats_cb _hidl_cb) { String8 halListValue; Result result = getParam(AudioParameter::keyStreamSupportedFormats, &halListValue); hidl_vec formats; - Vector halFormats; + FormatVector halFormats; if (result == Result::OK) { halFormats = formatsFromString(halListValue.string(), AudioParameter::valueListSeparator); formats.resize(halFormats.size());