1a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie/* 2a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * Copyright (C) 2009 The Android Open Source Project 3a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * 4a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * Licensed under the Apache License, Version 2.0 (the "License"); 5a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * you may not use this file except in compliance with the License. 6a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * You may obtain a copy of the License at 7a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * 8a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * http://www.apache.org/licenses/LICENSE-2.0 9a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * 10a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * Unless required by applicable law or agreed to in writing, software 11a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * distributed under the License is distributed on an "AS IS" BASIS, 12a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * See the License for the specific language governing permissions and 14a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie * limitations under the License. 15a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie */ 16a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 17a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#pragma once 18a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 19a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <AudioGain.h> 20f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie#include <VolumeCurve.h> 21a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <AudioPort.h> 22a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <AudioPatch.h> 23a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <DeviceDescriptor.h> 24a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <IOProfile.h> 25a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <HwModule.h> 26a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <AudioInputDescriptor.h> 27a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <AudioOutputDescriptor.h> 28a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <AudioPolicyMix.h> 29a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <EffectDescriptor.h> 30a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <SoundTriggerSession.h> 31a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie#include <SessionRoute.h> 32a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 33a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffienamespace android { 34a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 35a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieclass AudioPolicyConfig 36a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie{ 37a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffiepublic: 38a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie AudioPolicyConfig(HwModuleCollection &hwModules, 39a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie DeviceVector &availableOutputDevices, 40a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie DeviceVector &availableInputDevices, 41a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sp<DeviceDescriptor> &defaultOutputDevices, 42d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie bool &isSpeakerDrcEnabled, 43d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie VolumeCurvesCollection *volumes = nullptr) 44a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie : mHwModules(hwModules), 45a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mAvailableOutputDevices(availableOutputDevices), 46a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mAvailableInputDevices(availableInputDevices), 47a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mDefaultOutputDevices(defaultOutputDevices), 48d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie mVolumeCurves(volumes), 49a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mIsSpeakerDrcEnabled(isSpeakerDrcEnabled) 50a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie {} 51a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 52d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie void setVolumes(const VolumeCurvesCollection &volumes) 53d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie { 54d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie if (mVolumeCurves != nullptr) { 55d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie *mVolumeCurves = volumes; 56d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie } 57d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie } 58d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie 59a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie void setHwModules(const HwModuleCollection &hwModules) 60a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie { 61a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mHwModules = hwModules; 62a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 63a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 64f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie void addAvailableDevice(const sp<DeviceDescriptor> &availableDevice) 65f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie { 66f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie if (audio_is_output_device(availableDevice->type())) { 67f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie mAvailableOutputDevices.add(availableDevice); 68f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie } else if (audio_is_input_device(availableDevice->type())) { 69f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie mAvailableInputDevices.add(availableDevice); 70f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie } 71f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie } 72f4ad6e5637b6deccdac4b60615383f290b3806cfFrançois Gaffie 73a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie void addAvailableInputDevices(const DeviceVector &availableInputDevices) 74a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie { 75a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mAvailableInputDevices.add(availableInputDevices); 76a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 77a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 78a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie void addAvailableOutputDevices(const DeviceVector &availableOutputDevices) 79a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie { 80a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mAvailableOutputDevices.add(availableOutputDevices); 81a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 82a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 83a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie void setSpeakerDrcEnabled(bool isSpeakerDrcEnabled) 84a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie { 85a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mIsSpeakerDrcEnabled = isSpeakerDrcEnabled; 86a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 87a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 88a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie const HwModuleCollection getHwModules() const { return mHwModules; } 89a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 90a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie const DeviceVector &getAvailableInputDevices() const 91a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie { 92a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie return mAvailableInputDevices; 93a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 94a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 95a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie const DeviceVector &getAvailableOutputDevices() const 96a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie { 97a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie return mAvailableOutputDevices; 98a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 99a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 100a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie void setDefaultOutputDevice(const sp<DeviceDescriptor> &defaultDevice) 101a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie { 102a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mDefaultOutputDevices = defaultDevice; 103a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 104a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 105a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie const sp<DeviceDescriptor> &getDefaultOutputDevice() const { return mDefaultOutputDevices; } 106a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 107a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie void setDefault(void) 108a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie { 109a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mDefaultOutputDevices = new DeviceDescriptor(AUDIO_DEVICE_OUT_SPEAKER); 110a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sp<HwModule> module; 1111d4481fb9cb1ea149f79f2a5d22110af84fbc90bFrançois Gaffie sp<DeviceDescriptor> defaultInputDevice = new DeviceDescriptor(AUDIO_DEVICE_IN_BUILTIN_MIC); 112a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mAvailableOutputDevices.add(mDefaultOutputDevices); 113a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mAvailableInputDevices.add(defaultInputDevice); 114a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 115a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie module = new HwModule("primary"); 116a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 117a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sp<OutputProfile> outProfile; 118a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie outProfile = new OutputProfile(String8("primary")); 119a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie outProfile->attach(module); 120112b0af826aeca45855690b9c105b2cdf9938bbeFrançois Gaffie outProfile->addAudioProfile( 121112b0af826aeca45855690b9c105b2cdf9938bbeFrançois Gaffie new AudioProfile(AUDIO_FORMAT_PCM_16_BIT, AUDIO_CHANNEL_OUT_STEREO, 44100)); 122a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie outProfile->addSupportedDevice(mDefaultOutputDevices); 123a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie outProfile->setFlags(AUDIO_OUTPUT_FLAG_PRIMARY); 124a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie module->mOutputProfiles.add(outProfile); 125a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 126a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sp<InputProfile> inProfile; 127a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie inProfile = new InputProfile(String8("primary")); 128a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie inProfile->attach(module); 129112b0af826aeca45855690b9c105b2cdf9938bbeFrançois Gaffie inProfile->addAudioProfile( 130112b0af826aeca45855690b9c105b2cdf9938bbeFrançois Gaffie new AudioProfile(AUDIO_FORMAT_PCM_16_BIT, AUDIO_CHANNEL_IN_MONO, 8000)); 131a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie inProfile->addSupportedDevice(defaultInputDevice); 132a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie module->mInputProfiles.add(inProfile); 133a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 134a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie mHwModules.add(module); 135a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie } 136a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 137a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffieprivate: 138a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie HwModuleCollection &mHwModules; /**< Collection of Module, with Profiles, i.e. Mix Ports. */ 139a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie DeviceVector &mAvailableOutputDevices; 140a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie DeviceVector &mAvailableInputDevices; 141a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie sp<DeviceDescriptor> &mDefaultOutputDevices; 142d1ab2bd4f1ea166a7e9e81cfd7f3e5dd47135d4dFrançois Gaffie VolumeCurvesCollection *mVolumeCurves; 143a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie bool &mIsSpeakerDrcEnabled; 144a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; 145a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie 146a8ecc2c72ca26389bd6b0162181d60aaeaca8149François Gaffie}; // namespace android 147