blob: 33132249719a878934c69a2e701abd54d42cc79c [file] [log] [blame]
jiabin06e4bab2019-07-29 10:13:34 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
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
17#pragma once
18
19#include <set>
20#include <vector>
21
22#include <system/audio.h>
23
24namespace android {
25
26using ChannelMaskSet = std::set<audio_channel_mask_t>;
27using FormatSet = std::set<audio_format_t>;
28using SampleRateSet = std::set<uint32_t>;
29
30using FormatVector = std::vector<audio_format_t>;
31
32static inline ChannelMaskSet asInMask(const ChannelMaskSet& channelMasks) {
33 ChannelMaskSet inMaskSet;
34 for (const auto &channel : channelMasks) {
35 if (audio_channel_mask_out_to_in(channel) != AUDIO_CHANNEL_INVALID) {
36 inMaskSet.insert(audio_channel_mask_out_to_in(channel));
37 }
38 }
39 return inMaskSet;
40}
41
42static inline ChannelMaskSet asOutMask(const ChannelMaskSet& channelMasks) {
43 ChannelMaskSet outMaskSet;
44 for (const auto &channel : channelMasks) {
45 if (audio_channel_mask_in_to_out(channel) != AUDIO_CHANNEL_INVALID) {
46 outMaskSet.insert(audio_channel_mask_in_to_out(channel));
47 }
48 }
49 return outMaskSet;
50}
51
52} // namespace android