forked from Hashcode/android_hardware_alsa_sound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAudioPolicyManagerALSA.h
89 lines (79 loc) · 4.06 KB
/
AudioPolicyManagerALSA.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Copyright (C) 2009 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdint.h>
#include <sys/types.h>
#include <utils/Timers.h>
#include <utils/Errors.h>
#include <utils/KeyedVector.h>
#include <hardware_legacy/AudioPolicyManagerBase.h>
namespace android {
// ----------------------------------------------------------------------------
#define MAX_DEVICE_ADDRESS_LEN 20
// Attenuation applied to STRATEGY_SONIFICATION streams when a headset is connected: 6dB
#define SONIFICATION_HEADSET_VOLUME_FACTOR 0.5
// Min volume for STRATEGY_SONIFICATION streams when limited by music volume: -36dB
#define SONIFICATION_HEADSET_VOLUME_MIN 0.016
// Time in seconds during which we consider that music is still active after a music
// track was stopped - see computeVolume()
#define SONIFICATION_HEADSET_MUSIC_DELAY 5
class AudioPolicyManagerALSA: public AudioPolicyManagerBase
{
public:
AudioPolicyManagerALSA(AudioPolicyClientInterface *clientInterface);
virtual ~AudioPolicyManagerALSA();
status_t setDeviceConnectionState(AudioSystem::audio_devices device,
AudioSystem::device_connection_state state,
const char *device_address);
uint32_t getDeviceForStrategy(routing_strategy strategy, bool fromCache = true);
#if defined(HAS_FM_RADIO) || defined(OMAP_ENHANCEMENT)
/* get Fm input source */
audio_io_handle_t getFMInput(int inputSource,
uint32_t samplingRate,
uint32_t format,
uint32_t channels,
AudioSystem::audio_in_acoustics acoustics);
#endif
/* AudioPolicyManagerBase.cpp, in the stopoutoutput, setOutputDevice
* is called by force(with flag true) which is causing Core is not going
* to off/ret when A2DP is paused, Because output stream is activated
* during the A2DP pause (opens PCM stream).
* So we are overriding the stopOutput in Alsa vesrion of policy manger
* now setOutputDevice is called with flag false.
* */
status_t stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream);
/* In AudioPolicyManagerBase.cpp, in the getinput method if the inputsource
* is AUDIO_SOURCE_VOICE_CALL the channels bitfield is filled with
* (CHANNEL_IN_VOICE_UPLINK | CHANNEL_IN_VOICE_DNLINK) which force voice call
* record to be stereo. If the inputsource is AUDIO_SOURCE_VOICE_UPLINK or
* AUDIO_SOURCE_VOICE_DOWNLINK the channels bitfiled is set respectively to
* CHANNEL_IN_VOICE_UPLINK or CHANNEL_IN_VOICE_DNLINK in this case the
* voice call record is mono.
* So we are overriding the inputsource in Alsa version of policy manager
* to use a new channel bit CHANNEL_IN_VOICE_UPLINK_DNLINK to have also
* voice call record in mono in case of inputsource AUDIO_SOURCE_VOICE_CALL.
* */
#ifdef OMAP_ENHANCEMENT
audio_io_handle_t getInput(int inputSource,
uint32_t samplingRate,
uint32_t format,
uint32_t channels,
AudioSystem::audio_in_acoustics acoustics);
#endif
#if defined(HAS_FM_RADIO) || defined(OMAP_ENHANCEMENT)
audio_io_handle_t mfmInput; // FM input handler
#endif
};
};