blob: 3b809777a0bbd929bb0bf6137d5a8f3e4691eb79 [file] [log] [blame]
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -07001/*
2 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
3 * Not a contribution.
4 *
5 * Copyright (C) 2009 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20
21#include <stdint.h>
22#include <sys/types.h>
23#include <utils/Timers.h>
24#include <utils/Errors.h>
25#include <utils/KeyedVector.h>
26#include <hardware_legacy/AudioPolicyManagerBase.h>
27
28
29namespace android_audio_legacy {
30
31// ----------------------------------------------------------------------------
32
33class AudioPolicyManager: public AudioPolicyManagerBase
34{
35
36public:
37 AudioPolicyManager(AudioPolicyClientInterface *clientInterface)
38 : AudioPolicyManagerBase(clientInterface) {}
39
40 virtual ~AudioPolicyManager() {}
41
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -070042 virtual status_t setDeviceConnectionState(audio_devices_t device,
43 AudioSystem::device_connection_state state,
44 const char *device_address);
45 virtual void setForceUse(AudioSystem::force_use usage, AudioSystem::forced_config config);
46 virtual audio_io_handle_t getInput(int inputSource,
47 uint32_t samplingRate,
48 uint32_t format,
49 uint32_t channels,
50 AudioSystem::audio_in_acoustics acoustics);
ApurupaPattapu0c566872014-01-10 14:46:02 -080051 virtual bool isOffloadSupported(const audio_offload_info_t& offloadInfo);
Pavan Chikkalae33427d2014-03-24 17:11:50 +053052 virtual void setPhoneState(int state);
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -070053protected:
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -070054 // return the strategy corresponding to a given stream type
55 static routing_strategy getStrategy(AudioSystem::stream_type stream);
56
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -070057 // return appropriate device for streams handled by the specified strategy according to current
58 // phone state, connected devices...
59 // if fromCache is true, the device is returned from mDeviceForStrategy[],
60 // otherwise it is determine by current state
61 // (device connected,phone state, force use, a2dp output...)
62 // This allows to:
63 // 1 speed up process when the state is stable (when starting or stopping an output)
64 // 2 access to either current device selection (fromCache == true) or
65 // "future" device selection (fromCache == false) when called from a context
66 // where conditions are changing (setDeviceConnectionState(), setPhoneState()...) AND
67 // before updateDevicesAndOutputs() is called.
68 virtual audio_devices_t getDeviceForStrategy(routing_strategy strategy,
69 bool fromCache = true);
Ravi Kumar Alamanda88d28cb2013-10-15 16:59:57 -070070 // select input device corresponding to requested audio source
71 virtual audio_devices_t getDeviceForInputSource(int inputSource);
72
73 // compute the actual volume for a given stream according to the requested index and a particular
74 // device
75 virtual float computeVolume(int stream, int index, audio_io_handle_t output, audio_devices_t device);
76
77 // check that volume change is permitted, compute and send new volume to audio hardware
78 status_t checkAndSetVolume(int stream, int index, audio_io_handle_t output, audio_devices_t device, int delayMs = 0, bool force = false);
79
80 // returns the category the device belongs to with regard to volume curve management
81 static device_category getDeviceCategory(audio_devices_t device);
82
Karthik Reddy Katta521934f2014-06-09 12:39:37 +053083 // returns true if give output is direct output
84 bool isDirectOutput(audio_io_handle_t output);
85
Mingming Yin9d2feb72014-04-29 18:40:21 -070086 static const char* HDMI_SPKR_STR;
87
88 //parameter indicates of HDMI speakers disabled from the Qualcomm settings
89 bool mHdmiAudioDisabled;
90
91 //parameter indicates if HDMI plug in/out detected
92 bool mHdmiAudioEvent;
93
Pavan Chikkalae33427d2014-03-24 17:11:50 +053094private:
Mingming Yin9d2feb72014-04-29 18:40:21 -070095 // Used for voip + voice concurrency usecase
96 int mPrevPhoneState;
Pavan Chikkalae33427d2014-03-24 17:11:50 +053097
Ravi Kumar Alamanda89a81422013-10-08 23:47:55 -070098};
99};