blob: bb9e2df3a49698867e21b8ce3da93385f078a1b9 [file] [log] [blame]
François Gaffie2110e042015-03-24 08:41:51 +01001/*
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 Gaffiedc7553f2018-11-02 10:39:57 +010019#include "EngineBase.h"
Mikhail Naganov47835552019-05-14 10:32:51 -070020#include "EngineInterface.h"
François Gaffie2110e042015-03-24 08:41:51 +010021#include <policy.h>
22
23namespace android
24{
25
26class AudioPolicyManagerObserver;
27
28namespace audio_policy
29{
30
François Gaffiedc7553f2018-11-02 10:39:57 +010031enum 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,
Eric Laurent21777f82019-12-06 18:12:06 -080042 STRATEGY_CALL_ASSISTANT,
François Gaffiedc7553f2018-11-02 10:39:57 +010043};
44
45class Engine : public EngineBase
François Gaffie2110e042015-03-24 08:41:51 +010046{
47public:
48 Engine();
François Gaffiedc7553f2018-11-02 10:39:57 +010049 virtual ~Engine() = default;
François Gaffie2110e042015-03-24 08:41:51 +010050
François Gaffie2110e042015-03-24 08:41:51 +010051private:
François Gaffiedc7553f2018-11-02 10:39:57 +010052 ///
Mikhail Naganov47835552019-05-14 10:32:51 -070053 /// from EngineBase, so from EngineInterface
François Gaffiedc7553f2018-11-02 10:39:57 +010054 ///
François Gaffiedc7553f2018-11-02 10:39:57 +010055 status_t setForceUse(audio_policy_force_use_t usage,
56 audio_policy_forced_cfg_t config) override;
57
58 DeviceVector getOutputDevicesForAttributes(const audio_attributes_t &attr,
59 const sp<DeviceDescriptor> &preferedDevice = nullptr,
60 bool fromCache = false) const override;
61
62 DeviceVector getOutputDevicesForStream(audio_stream_type_t stream,
63 bool fromCache = false) const override;
64
65 sp<DeviceDescriptor> getInputDeviceForAttributes(
Mikhail Naganovbfac5832019-03-05 16:55:28 -080066 const audio_attributes_t &attr, sp<AudioPolicyMix> *mix = nullptr) const override;
François Gaffiedc7553f2018-11-02 10:39:57 +010067
68 void updateDeviceSelectionCache() override;
69
François Gaffie2110e042015-03-24 08:41:51 +010070private:
71 /* Copy facilities are put private to disable copy. */
72 Engine(const Engine &object);
73 Engine &operator=(const Engine &object);
74
François Gaffie2110e042015-03-24 08:41:51 +010075 status_t setDefaultDevice(audio_devices_t device);
76
jiabinf502d152019-08-07 14:43:33 -070077 DeviceVector getDevicesForStrategyInt(legacy_strategy strategy,
78 DeviceVector availableOutputDevices,
79 DeviceVector availableInputDevices,
80 const SwAudioOutputCollection &outputs) const;
François Gaffie2110e042015-03-24 08:41:51 +010081
François Gaffiedc7553f2018-11-02 10:39:57 +010082 DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const;
François Gaffie2110e042015-03-24 08:41:51 +010083
jiabinf502d152019-08-07 14:43:33 -070084 sp<DeviceDescriptor> getDeviceForInputSource(audio_source_t inputSource) const;
François Gaffie6054a772018-11-06 13:10:58 +010085
François Gaffiedc7553f2018-11-02 10:39:57 +010086 DeviceStrategyMap mDevicesForStrategies;
87
88 std::map<product_strategy_t, legacy_strategy> mLegacyStrategyMap;
François Gaffie2110e042015-03-24 08:41:51 +010089};
90} // namespace audio_policy
91} // namespace android
92