blob: 4360c6fe66a9b5df43085f8053fcd62540c11a3c [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,
42};
43
44class Engine : public EngineBase
François Gaffie2110e042015-03-24 08:41:51 +010045{
46public:
47 Engine();
François Gaffiedc7553f2018-11-02 10:39:57 +010048 virtual ~Engine() = default;
François Gaffie2110e042015-03-24 08:41:51 +010049
François Gaffie2110e042015-03-24 08:41:51 +010050private:
François Gaffiedc7553f2018-11-02 10:39:57 +010051 ///
Mikhail Naganov47835552019-05-14 10:32:51 -070052 /// from EngineBase, so from EngineInterface
François Gaffiedc7553f2018-11-02 10:39:57 +010053 ///
François Gaffiedc7553f2018-11-02 10:39:57 +010054 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 Naganovbfac5832019-03-05 16:55:28 -080065 const audio_attributes_t &attr, sp<AudioPolicyMix> *mix = nullptr) const override;
François Gaffiedc7553f2018-11-02 10:39:57 +010066
67 void updateDeviceSelectionCache() override;
68
François Gaffie2110e042015-03-24 08:41:51 +010069private:
70 /* Copy facilities are put private to disable copy. */
71 Engine(const Engine &object);
72 Engine &operator=(const Engine &object);
73
François Gaffie2110e042015-03-24 08:41:51 +010074 status_t setDefaultDevice(audio_devices_t device);
75
jiabinf502d152019-08-07 14:43:33 -070076 DeviceVector getDevicesForStrategyInt(legacy_strategy strategy,
77 DeviceVector availableOutputDevices,
78 DeviceVector availableInputDevices,
79 const SwAudioOutputCollection &outputs) const;
François Gaffie2110e042015-03-24 08:41:51 +010080
François Gaffiedc7553f2018-11-02 10:39:57 +010081 DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const;
François Gaffie2110e042015-03-24 08:41:51 +010082
jiabinf502d152019-08-07 14:43:33 -070083 sp<DeviceDescriptor> getDeviceForInputSource(audio_source_t inputSource) const;
François Gaffie6054a772018-11-06 13:10:58 +010084
François Gaffiedc7553f2018-11-02 10:39:57 +010085 DeviceStrategyMap mDevicesForStrategies;
86
87 std::map<product_strategy_t, legacy_strategy> mLegacyStrategyMap;
François Gaffie2110e042015-03-24 08:41:51 +010088};
89} // namespace audio_policy
90} // namespace android
91