blob: ec10bc9ee965f89a49c0fa0f9020296b82cce1f7 [file] [log] [blame]
François Gaffie112b0af2015-11-19 16:13:25 +01001/*
jiabin3e277cc2019-09-10 14:27:34 -07002 * Copyright (C) 2019 The Android Open Source Project
François Gaffie112b0af2015-11-19 16:13:25 +01003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Mikhail Naganovfa69dc62018-07-27 09:58:58 -070017#include <set>
Mikhail Naganove50f6282018-07-26 16:20:43 -070018
jiabin9bb3a1e2019-08-19 10:10:17 -070019#define LOG_TAG "AudioProfile"
François Gaffie112b0af2015-11-19 16:13:25 +010020//#define LOG_NDEBUG 0
21
jiabin9bb3a1e2019-08-19 10:10:17 -070022#include <android-base/stringprintf.h>
jiabin06e4bab2019-07-29 10:13:34 -070023#include <media/AudioContainers.h>
jiabin9bb3a1e2019-08-19 10:10:17 -070024#include <media/AudioProfile.h>
25#include <media/TypeConverter.h>
Mikhail Naganove50f6282018-07-26 16:20:43 -070026#include <utils/Errors.h>
27
François Gaffie112b0af2015-11-19 16:13:25 +010028namespace android {
29
Mikhail Naganov57bd06f2021-08-10 16:41:54 -070030using media::audio::common::AudioChannelLayout;
31
jiabin9bb3a1e2019-08-19 10:10:17 -070032bool operator == (const AudioProfile &left, const AudioProfile &right)
Mikhail Naganove50f6282018-07-26 16:20:43 -070033{
jiabin9bb3a1e2019-08-19 10:10:17 -070034 return (left.getFormat() == right.getFormat()) &&
35 (left.getChannels() == right.getChannels()) &&
36 (left.getSampleRates() == right.getSampleRates());
Mikhail Naganove50f6282018-07-26 16:20:43 -070037}
38
jiabin9bb3a1e2019-08-19 10:10:17 -070039// static
40sp<AudioProfile> AudioProfile::createFullDynamic(audio_format_t dynamicFormat)
Mikhail Naganov21b43362018-06-04 10:37:09 -070041{
jiabin9bb3a1e2019-08-19 10:10:17 -070042 AudioProfile* dynamicProfile = new AudioProfile(dynamicFormat,
jiabin06e4bab2019-07-29 10:13:34 -070043 ChannelMaskSet(), SampleRateSet());
Mikhail Naganov21b43362018-06-04 10:37:09 -070044 dynamicProfile->setDynamicFormat(true);
45 dynamicProfile->setDynamicChannels(true);
46 dynamicProfile->setDynamicRate(true);
47 return dynamicProfile;
48}
49
Mikhail Naganove50f6282018-07-26 16:20:43 -070050AudioProfile::AudioProfile(audio_format_t format,
51 audio_channel_mask_t channelMasks,
52 uint32_t samplingRate) :
jiabin9bb3a1e2019-08-19 10:10:17 -070053 mName(""),
Mikhail Naganove50f6282018-07-26 16:20:43 -070054 mFormat(format)
55{
jiabin06e4bab2019-07-29 10:13:34 -070056 mChannelMasks.insert(channelMasks);
57 mSamplingRates.insert(samplingRate);
Mikhail Naganove50f6282018-07-26 16:20:43 -070058}
59
60AudioProfile::AudioProfile(audio_format_t format,
jiabin06e4bab2019-07-29 10:13:34 -070061 const ChannelMaskSet &channelMasks,
62 const SampleRateSet &samplingRateCollection) :
jiabin82e56932021-03-05 06:35:19 +000063 AudioProfile(format, channelMasks, samplingRateCollection,
64 AUDIO_ENCAPSULATION_TYPE_NONE) {}
65
66AudioProfile::AudioProfile(audio_format_t format,
67 const ChannelMaskSet &channelMasks,
68 const SampleRateSet &samplingRateCollection,
69 audio_encapsulation_type_t encapsulationType) :
jiabin9bb3a1e2019-08-19 10:10:17 -070070 mName(""),
Mikhail Naganove50f6282018-07-26 16:20:43 -070071 mFormat(format),
72 mChannelMasks(channelMasks),
jiabin82e56932021-03-05 06:35:19 +000073 mSamplingRates(samplingRateCollection),
74 mEncapsulationType(encapsulationType) {}
Mikhail Naganove50f6282018-07-26 16:20:43 -070075
jiabin06e4bab2019-07-29 10:13:34 -070076void AudioProfile::setChannels(const ChannelMaskSet &channelMasks)
Mikhail Naganove50f6282018-07-26 16:20:43 -070077{
78 if (mIsDynamicChannels) {
79 mChannelMasks = channelMasks;
80 }
81}
82
jiabin06e4bab2019-07-29 10:13:34 -070083void AudioProfile::setSampleRates(const SampleRateSet &sampleRates)
Mikhail Naganove50f6282018-07-26 16:20:43 -070084{
85 if (mIsDynamicRate) {
86 mSamplingRates = sampleRates;
87 }
88}
89
90void AudioProfile::clear()
91{
92 if (mIsDynamicChannels) {
93 mChannelMasks.clear();
94 }
95 if (mIsDynamicRate) {
96 mSamplingRates.clear();
97 }
98}
99
jiabin9bb3a1e2019-08-19 10:10:17 -0700100void AudioProfile::dump(std::string *dst, int spaces) const
François Gaffie112b0af2015-11-19 16:13:25 +0100101{
Mikhail Naganov0dbe87b2021-12-01 02:03:31 +0000102 dst->append(base::StringPrintf("\"%s\"; ", mName.c_str()));
103 dst->append(base::StringPrintf("%s%s%s%s", mIsDynamicFormat ? "[dynamic format]" : "",
François Gaffie112b0af2015-11-19 16:13:25 +0100104 mIsDynamicChannels ? "[dynamic channels]" : "",
Mikhail Naganov0dbe87b2021-12-01 02:03:31 +0000105 mIsDynamicRate ? "[dynamic rates]" : "", isDynamic() ? "; " : ""));
106 dst->append(base::StringPrintf("%s (0x%x)\n", audio_format_to_string(mFormat), mFormat));
107
jiabin06e4bab2019-07-29 10:13:34 -0700108 if (!mSamplingRates.empty()) {
Mikhail Naganov0dbe87b2021-12-01 02:03:31 +0000109 dst->append(base::StringPrintf("%*ssampling rates: ", spaces, ""));
jiabin06e4bab2019-07-29 10:13:34 -0700110 for (auto it = mSamplingRates.begin(); it != mSamplingRates.end();) {
jiabin9bb3a1e2019-08-19 10:10:17 -0700111 dst->append(base::StringPrintf("%d", *it));
jiabin06e4bab2019-07-29 10:13:34 -0700112 dst->append(++it == mSamplingRates.end() ? "" : ", ");
François Gaffie112b0af2015-11-19 16:13:25 +0100113 }
Andy Hungbb54e202018-10-05 11:42:02 -0700114 dst->append("\n");
François Gaffie112b0af2015-11-19 16:13:25 +0100115 }
116
jiabin06e4bab2019-07-29 10:13:34 -0700117 if (!mChannelMasks.empty()) {
Mikhail Naganov0dbe87b2021-12-01 02:03:31 +0000118 dst->append(base::StringPrintf("%*schannel masks: ", spaces, ""));
jiabin06e4bab2019-07-29 10:13:34 -0700119 for (auto it = mChannelMasks.begin(); it != mChannelMasks.end();) {
jiabin9bb3a1e2019-08-19 10:10:17 -0700120 dst->append(base::StringPrintf("0x%04x", *it));
jiabin06e4bab2019-07-29 10:13:34 -0700121 dst->append(++it == mChannelMasks.end() ? "" : ", ");
François Gaffie112b0af2015-11-19 16:13:25 +0100122 }
Andy Hungbb54e202018-10-05 11:42:02 -0700123 dst->append("\n");
François Gaffie112b0af2015-11-19 16:13:25 +0100124 }
jiabin82e56932021-03-05 06:35:19 +0000125
126 dst->append(base::StringPrintf(
Mikhail Naganov0dbe87b2021-12-01 02:03:31 +0000127 "%*s%s\n", spaces, "", audio_encapsulation_type_to_string(mEncapsulationType)));
François Gaffie112b0af2015-11-19 16:13:25 +0100128}
129
jiabin49e69a12019-10-15 16:04:13 -0700130bool AudioProfile::equals(const sp<AudioProfile>& other) const
131{
132 return other != nullptr &&
133 mName.compare(other->mName) == 0 &&
134 mFormat == other->getFormat() &&
135 mChannelMasks == other->getChannels() &&
136 mSamplingRates == other->getSampleRates() &&
137 mIsDynamicFormat == other->isDynamicFormat() &&
138 mIsDynamicChannels == other->isDynamicChannels() &&
jiabin82e56932021-03-05 06:35:19 +0000139 mIsDynamicRate == other->isDynamicRate() &&
140 mEncapsulationType == other->getEncapsulationType();
jiabin49e69a12019-10-15 16:04:13 -0700141}
142
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800143AudioProfile& AudioProfile::operator=(const AudioProfile& other) {
144 mName = other.mName;
145 mFormat = other.mFormat;
146 mChannelMasks = other.mChannelMasks;
147 mSamplingRates = other.mSamplingRates;
jiabin82e56932021-03-05 06:35:19 +0000148 mEncapsulationType = other.mEncapsulationType;
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800149 mIsDynamicFormat = other.mIsDynamicFormat;
150 mIsDynamicChannels = other.mIsDynamicChannels;
151 mIsDynamicRate = other.mIsDynamicRate;
152 return *this;
jiabin17058fa2019-10-08 17:33:38 -0700153}
154
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000155ConversionResult<AudioProfile::Aidl>
Mikhail Naganovde3fa182021-07-30 15:06:42 -0700156AudioProfile::toParcelable(bool isInput) const {
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000157 media::audio::common::AudioProfile parcelable;
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800158 parcelable.name = mName;
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000159 parcelable.format = VALUE_OR_RETURN(
160 legacy2aidl_audio_format_t_AudioFormatDescription(mFormat));
161 // Note: legacy 'audio_profile' imposes a limit on the number of
162 // channel masks and sampling rates. That's why it's not used here
163 // and conversions are performed directly on the fields instead
164 // of using 'legacy2aidl_audio_profile_AudioProfile' from AidlConversion.
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800165 parcelable.channelMasks = VALUE_OR_RETURN(
Mikhail Naganov57bd06f2021-08-10 16:41:54 -0700166 convertContainer<std::vector<AudioChannelLayout>>(
Mikhail Naganov2d8df4e2021-06-03 13:59:13 -0700167 mChannelMasks,
Mikhail Naganovde3fa182021-07-30 15:06:42 -0700168 [isInput](audio_channel_mask_t m) {
169 return legacy2aidl_audio_channel_mask_t_AudioChannelLayout(m, isInput);
170 }));
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000171 parcelable.sampleRates = VALUE_OR_RETURN(
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800172 convertContainer<std::vector<int32_t>>(mSamplingRates,
173 convertIntegral<int32_t, uint32_t>));
jiabin82e56932021-03-05 06:35:19 +0000174 parcelable.encapsulationType = VALUE_OR_RETURN(
175 legacy2aidl_audio_encapsulation_type_t_AudioEncapsulationType(mEncapsulationType));
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000176 media::AudioProfileSys parcelableSys;
177 parcelableSys.isDynamicFormat = mIsDynamicFormat;
178 parcelableSys.isDynamicChannels = mIsDynamicChannels;
179 parcelableSys.isDynamicRate = mIsDynamicRate;
180 return std::make_pair(parcelable, parcelableSys);
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800181}
182
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000183ConversionResult<sp<AudioProfile>> AudioProfile::fromParcelable(
184 const AudioProfile::Aidl& aidl, bool isInput) {
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800185 sp<AudioProfile> legacy = new AudioProfile();
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000186 const auto& parcelable = aidl.first;
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800187 legacy->mName = parcelable.name;
Mikhail Naganovb60bd1b2021-07-15 17:31:43 -0700188 legacy->mFormat = VALUE_OR_RETURN(
189 aidl2legacy_AudioFormatDescription_audio_format_t(parcelable.format));
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800190 legacy->mChannelMasks = VALUE_OR_RETURN(
191 convertContainer<ChannelMaskSet>(parcelable.channelMasks,
Mikhail Naganov57bd06f2021-08-10 16:41:54 -0700192 [isInput](const AudioChannelLayout& l) {
Mikhail Naganovde3fa182021-07-30 15:06:42 -0700193 return aidl2legacy_AudioChannelLayout_audio_channel_mask_t(l, isInput);
194 }));
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800195 legacy->mSamplingRates = VALUE_OR_RETURN(
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000196 convertContainer<SampleRateSet>(parcelable.sampleRates,
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800197 convertIntegral<uint32_t, int32_t>));
jiabin82e56932021-03-05 06:35:19 +0000198 legacy->mEncapsulationType = VALUE_OR_RETURN(
199 aidl2legacy_AudioEncapsulationType_audio_encapsulation_type_t(
200 parcelable.encapsulationType));
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000201 const auto& parcelableSys = aidl.second;
202 legacy->mIsDynamicFormat = parcelableSys.isDynamicFormat;
203 legacy->mIsDynamicChannels = parcelableSys.isDynamicChannels;
204 legacy->mIsDynamicRate = parcelableSys.isDynamicRate;
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800205 return legacy;
206}
207
208ConversionResult<sp<AudioProfile>>
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000209aidl2legacy_AudioProfile(const AudioProfile::Aidl& aidl, bool isInput) {
Mikhail Naganovde3fa182021-07-30 15:06:42 -0700210 return AudioProfile::fromParcelable(aidl, isInput);
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800211}
212
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000213ConversionResult<AudioProfile::Aidl>
Mikhail Naganovde3fa182021-07-30 15:06:42 -0700214legacy2aidl_AudioProfile(const sp<AudioProfile>& legacy, bool isInput) {
215 return legacy->toParcelable(isInput);
jiabin17058fa2019-10-08 17:33:38 -0700216}
217
jiabin3e277cc2019-09-10 14:27:34 -0700218ssize_t AudioProfileVector::add(const sp<AudioProfile> &profile)
Mikhail Naganove50f6282018-07-26 16:20:43 -0700219{
jiabin06e4bab2019-07-29 10:13:34 -0700220 ssize_t index = size();
221 push_back(profile);
Mikhail Naganove50f6282018-07-26 16:20:43 -0700222 return index;
223}
224
jiabin3e277cc2019-09-10 14:27:34 -0700225void AudioProfileVector::clearProfiles()
Mikhail Naganove50f6282018-07-26 16:20:43 -0700226{
jiabin06e4bab2019-07-29 10:13:34 -0700227 for (auto it = begin(); it != end();) {
228 if ((*it)->isDynamicFormat() && (*it)->hasValidFormat()) {
229 it = erase(it);
230 } else {
231 (*it)->clear();
232 ++it;
Mikhail Naganove50f6282018-07-26 16:20:43 -0700233 }
Mikhail Naganove50f6282018-07-26 16:20:43 -0700234 }
235}
236
jiabin3e277cc2019-09-10 14:27:34 -0700237sp<AudioProfile> AudioProfileVector::getFirstValidProfile() const
Mikhail Naganove50f6282018-07-26 16:20:43 -0700238{
jiabin06e4bab2019-07-29 10:13:34 -0700239 for (const auto &profile : *this) {
240 if (profile->isValid()) {
241 return profile;
Mikhail Naganove50f6282018-07-26 16:20:43 -0700242 }
243 }
jiabin06e4bab2019-07-29 10:13:34 -0700244 return nullptr;
Mikhail Naganove50f6282018-07-26 16:20:43 -0700245}
246
jiabin3e277cc2019-09-10 14:27:34 -0700247sp<AudioProfile> AudioProfileVector::getFirstValidProfileFor(audio_format_t format) const
Mikhail Naganove50f6282018-07-26 16:20:43 -0700248{
jiabin06e4bab2019-07-29 10:13:34 -0700249 for (const auto &profile : *this) {
250 if (profile->isValid() && profile->getFormat() == format) {
251 return profile;
Mikhail Naganove50f6282018-07-26 16:20:43 -0700252 }
253 }
jiabin06e4bab2019-07-29 10:13:34 -0700254 return nullptr;
Mikhail Naganove50f6282018-07-26 16:20:43 -0700255}
256
jiabin3e277cc2019-09-10 14:27:34 -0700257FormatVector AudioProfileVector::getSupportedFormats() const
Mikhail Naganove50f6282018-07-26 16:20:43 -0700258{
259 FormatVector supportedFormats;
jiabin06e4bab2019-07-29 10:13:34 -0700260 for (const auto &profile : *this) {
261 if (profile->hasValidFormat()) {
262 supportedFormats.push_back(profile->getFormat());
Mikhail Naganove50f6282018-07-26 16:20:43 -0700263 }
264 }
265 return supportedFormats;
266}
267
jiabin3e277cc2019-09-10 14:27:34 -0700268bool AudioProfileVector::hasDynamicChannelsFor(audio_format_t format) const
Mikhail Naganove50f6282018-07-26 16:20:43 -0700269{
jiabin06e4bab2019-07-29 10:13:34 -0700270 for (const auto &profile : *this) {
Mikhail Naganove50f6282018-07-26 16:20:43 -0700271 if (profile->getFormat() == format && profile->isDynamicChannels()) {
272 return true;
273 }
274 }
275 return false;
276}
277
jiabin3e277cc2019-09-10 14:27:34 -0700278bool AudioProfileVector::hasDynamicFormat() const
jiabin9bb3a1e2019-08-19 10:10:17 -0700279{
280 for (const auto &profile : *this) {
281 if (profile->isDynamicFormat()) {
282 return true;
283 }
284 }
285 return false;
286}
287
jiabin3e277cc2019-09-10 14:27:34 -0700288bool AudioProfileVector::hasDynamicProfile() const
Mikhail Naganove50f6282018-07-26 16:20:43 -0700289{
jiabin06e4bab2019-07-29 10:13:34 -0700290 for (const auto &profile : *this) {
291 if (profile->isDynamic()) {
Mikhail Naganove50f6282018-07-26 16:20:43 -0700292 return true;
293 }
294 }
295 return false;
296}
297
jiabin3e277cc2019-09-10 14:27:34 -0700298bool AudioProfileVector::hasDynamicRateFor(audio_format_t format) const
Mikhail Naganove50f6282018-07-26 16:20:43 -0700299{
jiabin06e4bab2019-07-29 10:13:34 -0700300 for (const auto &profile : *this) {
Mikhail Naganove50f6282018-07-26 16:20:43 -0700301 if (profile->getFormat() == format && profile->isDynamicRate()) {
302 return true;
303 }
304 }
305 return false;
306}
307
jiabinb4fed192020-09-22 14:45:40 -0700308bool AudioProfileVector::contains(const sp<AudioProfile>& profile) const
309{
310 for (const auto& audioProfile : *this) {
311 if (audioProfile->equals(profile)) {
312 return true;
313 }
314 }
315 return false;
316}
317
jiabin3e277cc2019-09-10 14:27:34 -0700318void AudioProfileVector::dump(std::string *dst, int spaces) const
Mikhail Naganove50f6282018-07-26 16:20:43 -0700319{
Mikhail Naganov0dbe87b2021-12-01 02:03:31 +0000320 dst->append(base::StringPrintf("%*s- Profiles (%zu):\n", spaces - 2, "", size()));
Mikhail Naganove50f6282018-07-26 16:20:43 -0700321 for (size_t i = 0; i < size(); i++) {
Mikhail Naganov0dbe87b2021-12-01 02:03:31 +0000322 const std::string prefix = base::StringPrintf("%*s%zu. ", spaces + 1, "", i + 1);
323 dst->append(prefix);
jiabin9bb3a1e2019-08-19 10:10:17 -0700324 std::string profileStr;
Mikhail Naganov0dbe87b2021-12-01 02:03:31 +0000325 at(i)->dump(&profileStr, prefix.size());
jiabin9bb3a1e2019-08-19 10:10:17 -0700326 dst->append(profileStr);
Mikhail Naganove50f6282018-07-26 16:20:43 -0700327 }
328}
329
jiabin49e69a12019-10-15 16:04:13 -0700330bool AudioProfileVector::equals(const AudioProfileVector& other) const
331{
332 return std::equal(begin(), end(), other.begin(), other.end(),
333 [](const sp<AudioProfile>& left, const sp<AudioProfile>& right) {
334 return left->equals(right);
335 });
336}
337
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800338ConversionResult<AudioProfileVector>
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000339aidl2legacy_AudioProfileVector(const AudioProfileVector::Aidl& aidl, bool isInput) {
340 return convertContainers<AudioProfileVector>(aidl.first, aidl.second,
341 [isInput](const media::audio::common::AudioProfile& p,
342 const media::AudioProfileSys& ps) {
343 return aidl2legacy_AudioProfile(std::make_pair(p, ps), isInput);
Mikhail Naganovde3fa182021-07-30 15:06:42 -0700344 });
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800345}
346
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000347ConversionResult<AudioProfileVector::Aidl>
Mikhail Naganovde3fa182021-07-30 15:06:42 -0700348legacy2aidl_AudioProfileVector(const AudioProfileVector& legacy, bool isInput) {
Mikhail Naganov89818ba2021-09-21 20:37:13 +0000349 return convertContainerSplit<
350 std::vector<media::audio::common::AudioProfile>,
351 std::vector<media::AudioProfileSys>>(legacy,
Mikhail Naganovde3fa182021-07-30 15:06:42 -0700352 [isInput](const sp<AudioProfile>& p) {
353 return legacy2aidl_AudioProfile(p, isInput);
354 });
Ytai Ben-Tsvi50e016a2020-11-12 14:26:12 -0800355}
356
jiabinbce0c1d2020-10-05 11:20:18 -0700357AudioProfileVector intersectAudioProfiles(const AudioProfileVector& profiles1,
358 const AudioProfileVector& profiles2)
359{
360 std::map<audio_format_t, std::pair<ChannelMaskSet, SampleRateSet>> infos2;
361 for (const auto& profile : profiles2) {
362 infos2.emplace(profile->getFormat(),
363 std::make_pair(profile->getChannels(), profile->getSampleRates()));
364 }
365 AudioProfileVector profiles;
366 for (const auto& profile : profiles1) {
367 const auto it = infos2.find(profile->getFormat());
368 if (it == infos2.end()) {
369 continue;
370 }
371 ChannelMaskSet channelMasks = SetIntersection(profile->getChannels(), it->second.first);
372 if (channelMasks.empty()) {
373 continue;
374 }
375 SampleRateSet sampleRates = SetIntersection(profile->getSampleRates(), it->second.second);
376 if (sampleRates.empty()) {
377 continue;
378 }
379 profiles.push_back(new AudioProfile(profile->getFormat(), channelMasks, sampleRates));
380 }
381 return profiles;
382}
383
Mikhail Naganov1b2a7942017-12-08 10:18:09 -0800384} // namespace android