blob: 1fc22647c6dd93f58c22afd6a16b25448e307739 [file] [log] [blame]
François Gaffie20f06f92015-03-24 09:01:14 +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 Gaffief1e95082018-11-02 13:53:31 +010019#include <policy.h>
François Gaffie20f06f92015-03-24 09:01:14 +010020#include <EngineDefinition.h>
21#include <Volume.h>
22#include <system/audio.h>
François Gaffief1e95082018-11-02 13:53:31 +010023#include <media/AudioCommonTypes.h>
François Gaffie20f06f92015-03-24 09:01:14 +010024#include <utils/Errors.h>
25#include <string>
26#include <vector>
27
28namespace 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 */
36class AudioPolicyPluginInterface
37{
38public:
39 /**
François Gaffie20f06f92015-03-24 09:01:14 +010040 * 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 Gaffie20f06f92015-03-24 09:01:14 +010053 * 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 Gaffie20f06f92015-03-24 09:01:14 +010066 * 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 Gaffied1ab2bd2015-12-02 18:20:06 +010069 * @param[in] volumeProfile to follow for the given stream.
François Gaffie20f06f92015-03-24 09:01:14 +010070 *
François Gaffied1ab2bd2015-12-02 18:20:06 +010071 * @return true if the profile was set correclty for this stream, false otherwise.
François Gaffie20f06f92015-03-24 09:01:14 +010072 */
73 virtual bool setVolumeProfileForStream(const audio_stream_type_t &stream,
François Gaffied1ab2bd2015-12-02 18:20:06 +010074 const audio_stream_type_t &volumeProfile) = 0;
François Gaffie20f06f92015-03-24 09:01:14 +010075
76 /**
François Gaffie20f06f92015-03-24 09:01:14 +010077 * 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 Gaffief1e95082018-11-02 13:53:31 +010087 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 Gaffie20f06f92015-03-24 09:01:14 +0100103protected:
104 virtual ~AudioPolicyPluginInterface() {}
105};
106
Mikhail Naganov1b2a7942017-12-08 10:18:09 -0800107} // namespace android