François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +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 | f1e9508 | 2018-11-02 13:53:31 +0100 | [diff] [blame] | 19 | #include <policy.h> |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 20 | #include <EngineDefinition.h> |
| 21 | #include <Volume.h> |
| 22 | #include <system/audio.h> |
François Gaffie | f1e9508 | 2018-11-02 13:53:31 +0100 | [diff] [blame] | 23 | #include <media/AudioCommonTypes.h> |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 24 | #include <utils/Errors.h> |
| 25 | #include <string> |
| 26 | #include <vector> |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | /** |
| 31 | * This interface allows the parameter plugin to: |
| 32 | * - instantiate all the members of the policy engine (strategies, input sources, usages, profiles) |
| 33 | * - keep up to date the attributes of these policy members ( i.e. devices to be used for a |
| 34 | * strategy, strategy to be followed by a usage or a stream, ...) |
| 35 | */ |
| 36 | class AudioPolicyPluginInterface |
| 37 | { |
| 38 | public: |
| 39 | /** |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 40 | * Add a streams to the engine. |
| 41 | * |
| 42 | * @param[in] name of the stream to add |
| 43 | * @param[in] identifier: the numerical value associated to this member. It MUST match either |
| 44 | * system/audio.h or system/audio_policy.h enumration value in order to link the |
| 45 | * parameter controled by the PFW and the policy manager component. |
| 46 | * |
| 47 | * @return NO_ERROR if the stream has been added successfully, error code otherwise. |
| 48 | * |
| 49 | */ |
| 50 | virtual android::status_t addStream(const std::string &name, audio_stream_type_t id) = 0; |
| 51 | |
| 52 | /** |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 53 | * Add an input source to the engine |
| 54 | * |
| 55 | * @param[in] name of the input source to add |
| 56 | * @param[in] identifier: the numerical value associated to this member. It MUST match either |
| 57 | * system/audio.h or system/audio_policy.h enumration value in order to link the |
| 58 | * parameter controled by the PFW and the policy manager component. |
| 59 | * |
| 60 | * @return NO_ERROR if the input source has been added successfully, error code otherwise. |
| 61 | * |
| 62 | */ |
| 63 | virtual android::status_t addInputSource(const std::string &name, audio_source_t id) = 0; |
| 64 | |
| 65 | /** |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 66 | * Set the strategy to be followed by a stream. |
| 67 | * |
| 68 | * @param[in] stream: name of the stream for which the strategy to use has to be set |
François Gaffie | d1ab2bd | 2015-12-02 18:20:06 +0100 | [diff] [blame] | 69 | * @param[in] volumeProfile to follow for the given stream. |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 70 | * |
François Gaffie | d1ab2bd | 2015-12-02 18:20:06 +0100 | [diff] [blame] | 71 | * @return true if the profile was set correclty for this stream, false otherwise. |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 72 | */ |
| 73 | virtual bool setVolumeProfileForStream(const audio_stream_type_t &stream, |
François Gaffie | d1ab2bd | 2015-12-02 18:20:06 +0100 | [diff] [blame] | 74 | const audio_stream_type_t &volumeProfile) = 0; |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 75 | |
| 76 | /** |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 77 | * Set the input device to be used by an input source. |
| 78 | * |
| 79 | * @param[in] inputSource: name of the input source for which the device to use has to be set |
| 80 | * @param[in] devices; mask of devices to be used for the given input source. |
| 81 | * |
| 82 | * @return true if the devices were set correclty for this input source, false otherwise. |
| 83 | */ |
| 84 | virtual bool setDeviceForInputSource(const audio_source_t &inputSource, |
| 85 | audio_devices_t device) = 0; |
| 86 | |
François Gaffie | f1e9508 | 2018-11-02 13:53:31 +0100 | [diff] [blame] | 87 | virtual void setDeviceAddressForProductStrategy(product_strategy_t strategy, |
| 88 | const std::string &address) = 0; |
| 89 | |
| 90 | /** |
| 91 | * Set the device to be used by a product strategy. |
| 92 | * |
| 93 | * @param[in] strategy: name of the product strategy for which the device to use has to be set |
| 94 | * @param[in] devices; mask of devices to be used for the given strategy. |
| 95 | * |
| 96 | * @return true if the devices were set correclty for this strategy, false otherwise. |
| 97 | */ |
| 98 | virtual bool setDeviceTypesForProductStrategy(product_strategy_t strategy, |
| 99 | audio_devices_t devices) = 0; |
| 100 | |
| 101 | virtual product_strategy_t getProductStrategyByName(const std::string &address) = 0; |
| 102 | |
François Gaffie | 20f06f9 | 2015-03-24 09:01:14 +0100 | [diff] [blame] | 103 | protected: |
| 104 | virtual ~AudioPolicyPluginInterface() {} |
| 105 | }; |
| 106 | |
Mikhail Naganov | 1b2a794 | 2017-12-08 10:18:09 -0800 | [diff] [blame] | 107 | } // namespace android |