François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 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 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 19 | #include "EngineBase.h" |
Mikhail Naganov | 4783555 | 2019-05-14 10:32:51 -0700 | [diff] [blame] | 20 | #include "EngineInterface.h" |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 21 | #include <policy.h> |
| 22 | |
| 23 | namespace android |
| 24 | { |
| 25 | |
| 26 | class AudioPolicyManagerObserver; |
| 27 | |
| 28 | namespace audio_policy |
| 29 | { |
| 30 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 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 |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 45 | { |
| 46 | public: |
| 47 | Engine(); |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 48 | virtual ~Engine() = default; |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 49 | |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 50 | private: |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 51 | /// |
Mikhail Naganov | 4783555 | 2019-05-14 10:32:51 -0700 | [diff] [blame] | 52 | /// from EngineBase, so from EngineInterface |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 53 | /// |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 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( |
Mikhail Naganov | bfac583 | 2019-03-05 16:55:28 -0800 | [diff] [blame] | 65 | const audio_attributes_t &attr, sp<AudioPolicyMix> *mix = nullptr) const override; |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 66 | |
| 67 | void updateDeviceSelectionCache() override; |
| 68 | |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 69 | private: |
| 70 | /* Copy facilities are put private to disable copy. */ |
| 71 | Engine(const Engine &object); |
| 72 | Engine &operator=(const Engine &object); |
| 73 | |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 74 | status_t setDefaultDevice(audio_devices_t device); |
| 75 | |
jiabin | f502d15 | 2019-08-07 14:43:33 -0700 | [diff] [blame] | 76 | DeviceVector getDevicesForStrategyInt(legacy_strategy strategy, |
| 77 | DeviceVector availableOutputDevices, |
| 78 | DeviceVector availableInputDevices, |
| 79 | const SwAudioOutputCollection &outputs) const; |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 80 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 81 | DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const; |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 82 | |
jiabin | f502d15 | 2019-08-07 14:43:33 -0700 | [diff] [blame] | 83 | sp<DeviceDescriptor> getDeviceForInputSource(audio_source_t inputSource) const; |
François Gaffie | 6054a77 | 2018-11-06 13:10:58 +0100 | [diff] [blame] | 84 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 85 | DeviceStrategyMap mDevicesForStrategies; |
| 86 | |
| 87 | std::map<product_strategy_t, legacy_strategy> mLegacyStrategyMap; |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 88 | }; |
| 89 | } // namespace audio_policy |
| 90 | } // namespace android |
| 91 | |