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" |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 20 | #include "AudioPolicyManagerInterface.h" |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 21 | #include <AudioGain.h> |
| 22 | #include <policy.h> |
| 23 | |
| 24 | namespace android |
| 25 | { |
| 26 | |
| 27 | class AudioPolicyManagerObserver; |
| 28 | |
| 29 | namespace audio_policy |
| 30 | { |
| 31 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 32 | enum legacy_strategy { |
| 33 | STRATEGY_NONE = -1, |
| 34 | STRATEGY_MEDIA, |
| 35 | STRATEGY_PHONE, |
| 36 | STRATEGY_SONIFICATION, |
| 37 | STRATEGY_SONIFICATION_RESPECTFUL, |
| 38 | STRATEGY_DTMF, |
| 39 | STRATEGY_ENFORCED_AUDIBLE, |
| 40 | STRATEGY_TRANSMITTED_THROUGH_SPEAKER, |
| 41 | STRATEGY_ACCESSIBILITY, |
| 42 | STRATEGY_REROUTING, |
| 43 | }; |
| 44 | |
| 45 | class Engine : public EngineBase |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 46 | { |
| 47 | public: |
| 48 | Engine(); |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 49 | virtual ~Engine() = default; |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 50 | |
| 51 | template <class RequestedInterface> |
| 52 | RequestedInterface *queryInterface(); |
| 53 | |
| 54 | private: |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 55 | /// |
| 56 | /// from EngineBase, so from AudioPolicyManagerInterface |
| 57 | /// |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 58 | status_t setForceUse(audio_policy_force_use_t usage, |
| 59 | audio_policy_forced_cfg_t config) override; |
| 60 | |
| 61 | DeviceVector getOutputDevicesForAttributes(const audio_attributes_t &attr, |
| 62 | const sp<DeviceDescriptor> &preferedDevice = nullptr, |
| 63 | bool fromCache = false) const override; |
| 64 | |
| 65 | DeviceVector getOutputDevicesForStream(audio_stream_type_t stream, |
| 66 | bool fromCache = false) const override; |
| 67 | |
| 68 | sp<DeviceDescriptor> getInputDeviceForAttributes( |
Mikhail Naganov | bfac583 | 2019-03-05 16:55:28 -0800 | [diff] [blame] | 69 | const audio_attributes_t &attr, sp<AudioPolicyMix> *mix = nullptr) const override; |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 70 | |
| 71 | void updateDeviceSelectionCache() override; |
| 72 | |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 73 | private: |
| 74 | /* Copy facilities are put private to disable copy. */ |
| 75 | Engine(const Engine &object); |
| 76 | Engine &operator=(const Engine &object); |
| 77 | |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 78 | status_t setDefaultDevice(audio_devices_t device); |
| 79 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 80 | audio_devices_t getDeviceForStrategyInt(legacy_strategy strategy, |
| 81 | DeviceVector availableOutputDevices, |
| 82 | DeviceVector availableInputDevices, |
| 83 | const SwAudioOutputCollection &outputs, |
| 84 | uint32_t outputDeviceTypesToIgnore) const; |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 85 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 86 | DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const; |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 87 | |
François Gaffie | 6054a77 | 2018-11-06 13:10:58 +0100 | [diff] [blame] | 88 | audio_devices_t getDeviceForInputSource(audio_source_t inputSource) const; |
| 89 | |
François Gaffie | dc7553f | 2018-11-02 10:39:57 +0100 | [diff] [blame] | 90 | DeviceStrategyMap mDevicesForStrategies; |
| 91 | |
| 92 | std::map<product_strategy_t, legacy_strategy> mLegacyStrategyMap; |
François Gaffie | 2110e04 | 2015-03-24 08:41:51 +0100 | [diff] [blame] | 93 | }; |
| 94 | } // namespace audio_policy |
| 95 | } // namespace android |
| 96 | |