1 /*
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 
19 #include <StreamDescriptor.h>
20 #include <utils/KeyedVector.h>
21 #include <system/audio.h>
22 #include <utils/Errors.h>
23 #include <utils/RefBase.h>
24 
25 namespace android {
26 
27 class StreamDescriptor;
28 
29 class Gains
30 {
31 public :
32     static float volIndexToDb(const VolumeCurvePoint *point, int indexMin, int indexMax,
33                               int indexInUi);
34 
35     // default volume curve
36     static const VolumeCurvePoint sDefaultVolumeCurve[Volume::VOLCNT];
37     // default volume curve for media strategy
38     static const VolumeCurvePoint sDefaultMediaVolumeCurve[Volume::VOLCNT];
39     // volume curve for non-media audio on ext media outputs (HDMI, Line, etc)
40     static const VolumeCurvePoint sExtMediaSystemVolumeCurve[Volume::VOLCNT];
41     // volume curve for media strategy on speakers
42     static const VolumeCurvePoint sSpeakerMediaVolumeCurve[Volume::VOLCNT];
43     static const VolumeCurvePoint sSpeakerMediaVolumeCurveDrc[Volume::VOLCNT];
44     // volume curve for sonification strategy on speakers
45     static const VolumeCurvePoint sSpeakerSonificationVolumeCurve[Volume::VOLCNT];
46     static const VolumeCurvePoint sSpeakerSonificationVolumeCurveDrc[Volume::VOLCNT];
47     static const VolumeCurvePoint sDefaultSystemVolumeCurve[Volume::VOLCNT];
48     static const VolumeCurvePoint sDefaultSystemVolumeCurveDrc[Volume::VOLCNT];
49     static const VolumeCurvePoint sHeadsetSystemVolumeCurve[Volume::VOLCNT];
50     static const VolumeCurvePoint sDefaultVoiceVolumeCurve[Volume::VOLCNT];
51     static const VolumeCurvePoint sSpeakerVoiceVolumeCurve[Volume::VOLCNT];
52     static const VolumeCurvePoint sLinearVolumeCurve[Volume::VOLCNT];
53     static const VolumeCurvePoint sSilentVolumeCurve[Volume::VOLCNT];
54     static const VolumeCurvePoint sFullScaleVolumeCurve[Volume::VOLCNT];
55     // default volume curves per stream and device category. See initializeVolumeCurves()
56     static const VolumeCurvePoint *sVolumeProfiles[AUDIO_STREAM_CNT][DEVICE_CATEGORY_CNT];
57 };
58 
59 }; // namespace android
60