1 /* 2 * Copyright (C) 2015 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 <media/AudioProfile.h> 20 #include <system/audio.h> 21 22 namespace android { 23 24 void sortAudioProfiles(AudioProfileVector &audioProfileVector); 25 26 ssize_t addAudioProfileAndSort(AudioProfileVector &audioProfileVector, 27 const sp<AudioProfile> &profile); 28 29 // One audio profile will be added for each format supported by Audio HAL 30 void addProfilesForFormats(AudioProfileVector &audioProfileVector, 31 const FormatVector &formatVector); 32 33 // This API is intended to be used by the policy manager once retrieving capabilities 34 // for a profile with dynamic format, rate and channels attributes 35 void addDynamicAudioProfileAndSort(AudioProfileVector &audioProfileVector, 36 const sp<AudioProfile> &profileToAdd); 37 38 void appendAudioProfiles(AudioProfileVector &audioProfileVector, 39 const AudioProfileVector &audioProfileVectorToAppend); 40 41 status_t checkExactProfile(const AudioProfileVector &audioProfileVector, 42 const uint32_t samplingRate, 43 audio_channel_mask_t channelMask, 44 audio_format_t format); 45 46 status_t checkCompatibleProfile(const AudioProfileVector &audioProfileVector, 47 uint32_t &samplingRate, 48 audio_channel_mask_t &channelMask, 49 audio_format_t &format, 50 audio_port_type_t portType, 51 audio_port_role_t portRole); 52 53 // Assuming that this profile vector contains input profiles, 54 // find the best matching config from 'outputProfiles', according to 55 // the given preferences for audio formats and channel masks. 56 // Note: std::vectors are used because specialized containers for formats 57 // and channels can be sorted and use their own ordering. 58 status_t findBestMatchingOutputConfig( 59 const AudioProfileVector &audioProfileVector, 60 const AudioProfileVector &outputProfileVector, 61 const std::vector<audio_format_t> &preferredFormatVector, // order: most pref -> least pref 62 const std::vector<audio_channel_mask_t> &preferredOutputChannelVector, 63 bool preferHigherSamplingRates, 64 audio_config_base &bestOutputConfig); 65 66 67 } // namespace android