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 "EngineBase.h" 20 #include "EngineInterface.h" 21 #include <policy.h> 22 23 namespace android 24 { 25 26 class AudioPolicyManagerObserver; 27 28 namespace audio_policy 29 { 30 31 enum legacy_strategy { 32 STRATEGY_NONE = -1, 33 STRATEGY_MEDIA, 34 STRATEGY_PHONE, 35 STRATEGY_SONIFICATION, 36 STRATEGY_SONIFICATION_RESPECTFUL, 37 STRATEGY_DTMF, 38 STRATEGY_ENFORCED_AUDIBLE, 39 STRATEGY_TRANSMITTED_THROUGH_SPEAKER, 40 STRATEGY_ACCESSIBILITY, 41 STRATEGY_REROUTING, 42 }; 43 44 class Engine : public EngineBase 45 { 46 public: 47 Engine(); 48 virtual ~Engine() = default; 49 50 private: 51 /// 52 /// from EngineBase, so from EngineInterface 53 /// 54 status_t setForceUse(audio_policy_force_use_t usage, 55 audio_policy_forced_cfg_t config) override; 56 57 DeviceVector getOutputDevicesForAttributes(const audio_attributes_t &attr, 58 const sp<DeviceDescriptor> &preferedDevice = nullptr, 59 bool fromCache = false) const override; 60 61 DeviceVector getOutputDevicesForStream(audio_stream_type_t stream, 62 bool fromCache = false) const override; 63 64 sp<DeviceDescriptor> getInputDeviceForAttributes( 65 const audio_attributes_t &attr, sp<AudioPolicyMix> *mix = nullptr) const override; 66 67 void updateDeviceSelectionCache() override; 68 69 private: 70 /* Copy facilities are put private to disable copy. */ 71 Engine(const Engine &object); 72 Engine &operator=(const Engine &object); 73 74 status_t setDefaultDevice(audio_devices_t device); 75 76 DeviceVector getDevicesForStrategyInt(legacy_strategy strategy, 77 DeviceVector availableOutputDevices, 78 DeviceVector availableInputDevices, 79 const SwAudioOutputCollection &outputs) const; 80 81 DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const; 82 83 sp<DeviceDescriptor> getDeviceForInputSource(audio_source_t inputSource) const; 84 85 DeviceStrategyMap mDevicesForStrategies; 86 87 std::map<product_strategy_t, legacy_strategy> mLegacyStrategyMap; 88 }; 89 } // namespace audio_policy 90 } // namespace android 91 92