blob: d5dfacce4e3b39e1c01eb190e143272a87fdd9e8 [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"
François Gaffie2110e042015-03-24 08:41:51 +010020#include "AudioPolicyManagerInterface.h"
François Gaffie2110e042015-03-24 08:41:51 +010021#include <AudioGain.h>
22#include <policy.h>
23
24namespace android
25{
26
27class AudioPolicyManagerObserver;
28
29namespace audio_policy
30{
31
François Gaffiedc7553f2018-11-02 10:39:57 +010032enum 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
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
51 template <class RequestedInterface>
52 RequestedInterface *queryInterface();
53
54private:
François Gaffiedc7553f2018-11-02 10:39:57 +010055 ///
56 /// from EngineBase, so from AudioPolicyManagerInterface
57 ///
François Gaffiedc7553f2018-11-02 10:39:57 +010058 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 Naganovbfac5832019-03-05 16:55:28 -080069 const audio_attributes_t &attr, sp<AudioPolicyMix> *mix = nullptr) const override;
François Gaffiedc7553f2018-11-02 10:39:57 +010070
71 void updateDeviceSelectionCache() override;
72
François Gaffie2110e042015-03-24 08:41:51 +010073private:
74 /* Copy facilities are put private to disable copy. */
75 Engine(const Engine &object);
76 Engine &operator=(const Engine &object);
77
François Gaffie2110e042015-03-24 08:41:51 +010078 status_t setDefaultDevice(audio_devices_t device);
79
François Gaffiedc7553f2018-11-02 10:39:57 +010080 audio_devices_t getDeviceForStrategyInt(legacy_strategy strategy,
81 DeviceVector availableOutputDevices,
82 DeviceVector availableInputDevices,
83 const SwAudioOutputCollection &outputs,
84 uint32_t outputDeviceTypesToIgnore) const;
François Gaffie2110e042015-03-24 08:41:51 +010085
François Gaffiedc7553f2018-11-02 10:39:57 +010086 DeviceVector getDevicesForProductStrategy(product_strategy_t strategy) const;
François Gaffie2110e042015-03-24 08:41:51 +010087
François Gaffie6054a772018-11-06 13:10:58 +010088 audio_devices_t getDeviceForInputSource(audio_source_t inputSource) const;
89
François Gaffiedc7553f2018-11-02 10:39:57 +010090 DeviceStrategyMap mDevicesForStrategies;
91
92 std::map<product_strategy_t, legacy_strategy> mLegacyStrategyMap;
François Gaffie2110e042015-03-24 08:41:51 +010093};
94} // namespace audio_policy
95} // namespace android
96