12110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie/*
22110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * Copyright (C) 2015 The Android Open Source Project
32110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie *
42110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * Licensed under the Apache License, Version 2.0 (the "License");
52110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * you may not use this file except in compliance with the License.
62110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * You may obtain a copy of the License at
72110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie *
82110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie *      http://www.apache.org/licenses/LICENSE-2.0
92110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie *
102110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * Unless required by applicable law or agreed to in writing, software
112110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * distributed under the License is distributed on an "AS IS" BASIS,
122110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * See the License for the specific language governing permissions and
142110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * limitations under the License.
152110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie */
162110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
172110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#pragma once
182110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
192110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#include <AudioPolicyManagerObserver.h>
202110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#include <RoutingStrategy.h>
212110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#include <Volume.h>
222110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#include <HwModule.h>
232110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#include <DeviceDescriptor.h>
242110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#include <system/audio.h>
252110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#include <system/audio_policy.h>
262110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#include <utils/Errors.h>
272110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie#include <utils/Vector.h>
282110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
292110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffienamespace android {
302110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
312110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie/**
322110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie * This interface is dedicated to the policy manager that a Policy Engine shall implement.
332110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie */
342110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffieclass AudioPolicyManagerInterface
352110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie{
362110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffiepublic:
372110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
382110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Checks if the engine was correctly initialized.
392110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
402110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @return NO_ERROR if initialization has been done correctly, error code otherwise..
412110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
422110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual status_t initCheck() = 0;
432110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
442110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
452110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Sets the Manager observer that allows the engine to retrieve information on collection
462110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * of devices, streams, HwModules, ...
472110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
482110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] observer handle on the manager.
492110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
502110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual void setObserver(AudioPolicyManagerObserver *observer) = 0;
512110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
522110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
532110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Get the input device selected for a given input source.
542110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
552110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] inputSource to get the selected input device associated to
562110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
572110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @return selected input device for the given input source, may be none if error.
582110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
592110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual audio_devices_t getDeviceForInputSource(audio_source_t inputSource) const = 0;
602110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
612110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
622110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Get the output device associated to a given strategy.
632110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
642110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] stream type for which the selected ouput device is requested.
652110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
662110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @return selected ouput device for the given strategy, may be none if error.
672110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
682110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual audio_devices_t getDeviceForStrategy(routing_strategy stategy) const = 0;
692110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
702110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
712110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Get the strategy selected for a given stream type.
722110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
732110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] stream: for which the selected strategy followed by is requested.
742110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
752110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @return strategy to be followed.
762110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
772110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual routing_strategy getStrategyForStream(audio_stream_type_t stream) = 0;
782110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
792110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
802110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Get the strategy selected for a given usage.
812110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
822110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] usage to get the selected strategy followed by.
832110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
842110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @return strategy to be followed.
852110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
862110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual routing_strategy getStrategyForUsage(audio_usage_t usage) = 0;
872110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
882110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
892110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Set the Telephony Mode.
902110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
912110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] mode: Android Phone state (normal, ringtone, csv, in communication)
922110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
932110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @return NO_ERROR if Telephony Mode set correctly, error code otherwise.
942110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
952110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual status_t setPhoneState(audio_mode_t mode) = 0;
962110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
972110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
982110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Get the telephony Mode
992110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
1002110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @return the current telephony mode
1012110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
1022110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual audio_mode_t getPhoneState() const = 0;
1032110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
1042110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
1052110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Set Force Use config for a given usage.
1062110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
1072110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] usage for which a configuration shall be forced.
1082110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] config wished to be forced for the given usage.
1092110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
11020f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * @return NO_ERROR if the Force Use config was set correctly, error code otherwise (e.g. config
11120f06f996337c9bf79d0b112083f6427a122ebabFrançois Gaffie     * not allowed a given usage...)
1122110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
1132110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual status_t setForceUse(audio_policy_force_use_t usage,
1142110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie                                 audio_policy_forced_cfg_t config) = 0;
1152110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
1162110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
1172110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Get Force Use config for a given usage.
1182110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
1192110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] usage for which a configuration shall be forced.
1202110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
1212110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @return config wished to be forced for the given usage.
1222110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
1232110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual audio_policy_forced_cfg_t getForceUse(audio_policy_force_use_t usage) const = 0;
1242110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
1252110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    /**
1262110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * Set the connection state of device(s).
1272110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
1282110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] devDesc for which the state has changed.
1292110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @param[in] state of availability of this(these) device(s).
1302110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     *
1312110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     * @return NO_ERROR if devices criterion updated correctly, error code otherwise.
1322110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie     */
1332110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual status_t setDeviceConnectionState(const android::sp<android::DeviceDescriptor> devDesc,
1342110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie                                              audio_policy_dev_state_t state) = 0;
1352110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
1362110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffieprotected:
1372110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie    virtual ~AudioPolicyManagerInterface() {}
1382110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie};
1392110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie
1402110e04cdfbf9ad85ce154ce5f778ee5ccfc95ebFrançois Gaffie}; // namespace android
141