120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie/*
220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * Copyright (C) 2015 The Android Open Source Project
320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie *
420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * Licensed under the Apache License, Version 2.0 (the "License");
520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * you may not use this file except in compliance with the License.
620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * You may obtain a copy of the License at
720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie *
820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie *      http://www.apache.org/licenses/LICENSE-2.0
920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie *
1020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * Unless required by applicable law or agreed to in writing, software
1120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * distributed under the License is distributed on an "AS IS" BASIS,
1220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * See the License for the specific language governing permissions and
1420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * limitations under the License.
1520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie */
1620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
1720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#pragma once
1820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
1920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#include <RoutingStrategy.h>
2020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#include <EngineDefinition.h>
2120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#include <Volume.h>
2220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#include <system/audio.h>
2320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#include <utils/Errors.h>
2420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#include <string>
2520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie#include <vector>
2620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
2720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffienamespace android {
2820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
2920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie/**
3020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie * This interface allows the parameter plugin to:
3120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie *  - instantiate all the members of the policy engine (strategies, input sources, usages, profiles)
3220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie *  - keep up to date the attributes of these policy members ( i.e. devices to be used for a
3320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie *    strategy, strategy to be followed by a usage or a stream, ...)
3420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie */
3520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffieclass AudioPolicyPluginInterface
3620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie{
3720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffiepublic:
3820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    /**
3920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * Add a strategy to the engine
4020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
4120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] name of the strategy to add
4220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] identifier: the numerical value associated to this member. It MUST match either
4320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *            system/audio.h or system/audio_policy.h enumration value in order to link the
4420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *            parameter controled by the PFW and the policy manager component.
4520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
4620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return NO_ERROR if the strategy has been added successfully, error code otherwise.
4720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
4820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     */
4920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual android::status_t addStrategy(const std::string &name, routing_strategy id) = 0;
5020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
5120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    /**
5220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * Add a streams to the engine.
5320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
5420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] name of the stream to add
5520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] identifier: the numerical value associated to this member. It MUST match either
5620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *            system/audio.h or system/audio_policy.h enumration value in order to link the
5720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *            parameter controled by the PFW and the policy manager component.
5820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
5920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return NO_ERROR if the stream has been added successfully, error code otherwise.
6020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
6120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     */
6220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual android::status_t addStream(const std::string &name, audio_stream_type_t id) = 0;
6320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
6420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    /**
6520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * Add a usage to the engine
6620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
6720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] name of the usage to add
6820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] identifier: the numerical value associated to this member. It MUST match either
6920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *            system/audio.h or system/audio_policy.h enumration value in order to link the
7020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *            parameter controled by the PFW and the policy manager component.
7120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
7220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return NO_ERROR if the usage has been added successfully, error code otherwise.
7320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
7420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     */
7520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual android::status_t addUsage(const std::string &name, audio_usage_t id) = 0;
7620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
7720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    /**
7820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * Add an input source to the engine
7920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
8020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] name of the input source to add
8120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] identifier: the numerical value associated to this member. It MUST match either
8220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *            system/audio.h or system/audio_policy.h enumration value in order to link the
8320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *            parameter controled by the PFW and the policy manager component.
8420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
8520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return NO_ERROR if the input source has been added successfully, error code otherwise.
8620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
8720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     */
8820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual android::status_t addInputSource(const std::string &name, audio_source_t id) = 0;
8920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
9020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    /**
9120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * Set the device to be used by a strategy.
9220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
9320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] strategy: name of the strategy for which the device to use has to be set
9420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] devices; mask of devices to be used for the given strategy.
9520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
9620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return true if the devices were set correclty for this strategy, false otherwise.
9720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     */
9820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual bool setDeviceForStrategy(const routing_strategy &strategy, audio_devices_t devices) = 0;
9920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
10020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    /**
10120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * Set the strategy to be followed by a stream.
10220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
10320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] stream: name of the stream for which the strategy to use has to be set
10420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] strategy to follow for the given stream.
10520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
10620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return true if the strategy were set correclty for this stream, false otherwise.
10720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     */
10820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual bool setStrategyForStream(const audio_stream_type_t &stream, routing_strategy strategy) = 0;
10920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
11020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    /**
11120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * Set the strategy to be followed by a stream.
11220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
11320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] stream: name of the stream for which the strategy to use has to be set
11420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] strategy to follow for the given stream.
11520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
11620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return true if the strategy were set correclty for this stream, false otherwise.
11720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     */
11820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual bool setVolumeProfileForStream(const audio_stream_type_t &stream,
11920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie                                           Volume::device_category category,
12020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie                                           const VolumeCurvePoints &points) = 0;
12120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
12220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    /**
12320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * Set the strategy to be followed by a usage.
12420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
12520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] usage: name of the usage for which the strategy to use has to be set
12620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] strategy to follow for the given usage.
12720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
12820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return true if the strategy were set correclty for this usage, false otherwise.
12920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     */
13020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual bool setStrategyForUsage(const audio_usage_t &usage, routing_strategy strategy) = 0;
13120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
13220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    /**
13320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * Set the input device to be used by an input source.
13420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
13520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] inputSource: name of the input source for which the device to use has to be set
13620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @param[in] devices; mask of devices to be used for the given input source.
13720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     *
13820f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return true if the devices were set correclty for this input source, false otherwise.
13920f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     */
14020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual bool setDeviceForInputSource(const audio_source_t &inputSource,
14120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie                                         audio_devices_t device) = 0;
14220f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
14320f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffieprotected:
14420f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie    virtual ~AudioPolicyPluginInterface() {}
14520f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie};
14620f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie
14720f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie}; // namespace android
148