summaryrefslogtreecommitdiffstats
path: root/services/audiopolicy/common/managerdefinitions/src
diff options
context:
space:
mode:
authorFrançois Gaffie <francois.gaffie@intel.com>2015-03-24 08:41:51 +0100
committerJean-Michel Trivi <jmtrivi@google.com>2015-04-01 10:22:42 -0700
commit2110e04cdfbf9ad85ce154ce5f778ee5ccfc95eb (patch)
tree5051da296e1fbc067db7ac190334d7d98a4410eb /services/audiopolicy/common/managerdefinitions/src
parentdfd7409c1b708f6c429aa43722ca8493a91d8df0 (diff)
downloadframeworks_av-2110e04cdfbf9ad85ce154ce5f778ee5ccfc95eb.zip
frameworks_av-2110e04cdfbf9ad85ce154ce5f778ee5ccfc95eb.tar.gz
frameworks_av-2110e04cdfbf9ad85ce154ce5f778ee5ccfc95eb.tar.bz2
Split ManagerDefault into manager and engine
This patch defines an interface for a new component: policy engine. The APIs found under this interface are the one we may want to customize and to configure easily. This patch also split the current manager code into manager and engine to provide a default version of the policy engine. Change-Id: I97cf59760b53d248fe9efe466ae5e73bd7e5cc06 Signed-off-by: François Gaffie <francois.gaffie@intel.com>
Diffstat (limited to 'services/audiopolicy/common/managerdefinitions/src')
-rw-r--r--services/audiopolicy/common/managerdefinitions/src/AudioGain.cpp214
1 files changed, 0 insertions, 214 deletions
diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioGain.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioGain.cpp
index ffe22ed..fc7b0cc 100644
--- a/services/audiopolicy/common/managerdefinitions/src/AudioGain.cpp
+++ b/services/audiopolicy/common/managerdefinitions/src/AudioGain.cpp
@@ -33,220 +33,6 @@
namespace android {
-const VolumeCurvePoint
-ApmGains::sDefaultVolumeCurve[Volume::VOLCNT] = {
- {1, -49.5f}, {33, -33.5f}, {66, -17.0f}, {100, 0.0f}
-};
-
-
-const VolumeCurvePoint
-ApmGains::sDefaultMediaVolumeCurve[Volume::VOLCNT] = {
- {1, -58.0f}, {20, -40.0f}, {60, -17.0f}, {100, 0.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sExtMediaSystemVolumeCurve[Volume::VOLCNT] = {
- {1, -58.0f}, {20, -40.0f}, {60, -21.0f}, {100, -10.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sSpeakerMediaVolumeCurve[Volume::VOLCNT] = {
- {1, -56.0f}, {20, -34.0f}, {60, -11.0f}, {100, 0.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sSpeakerMediaVolumeCurveDrc[Volume::VOLCNT] = {
- {1, -55.0f}, {20, -43.0f}, {86, -12.0f}, {100, 0.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sSpeakerSonificationVolumeCurve[Volume::VOLCNT] = {
- {1, -29.7f}, {33, -20.1f}, {66, -10.2f}, {100, 0.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sSpeakerSonificationVolumeCurveDrc[Volume::VOLCNT] = {
- {1, -35.7f}, {33, -26.1f}, {66, -13.2f}, {100, 0.0f}
-};
-
-// AUDIO_STREAM_SYSTEM, AUDIO_STREAM_ENFORCED_AUDIBLE and AUDIO_STREAM_DTMF volume tracks
-// AUDIO_STREAM_RING on phones and AUDIO_STREAM_MUSIC on tablets.
-// AUDIO_STREAM_DTMF tracks AUDIO_STREAM_VOICE_CALL while in call (See AudioService.java).
-// The range is constrained between -24dB and -6dB over speaker and -30dB and -18dB over headset.
-
-const VolumeCurvePoint
-ApmGains::sDefaultSystemVolumeCurve[Volume::VOLCNT] = {
- {1, -24.0f}, {33, -18.0f}, {66, -12.0f}, {100, -6.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sDefaultSystemVolumeCurveDrc[Volume::VOLCNT] = {
- {1, -34.0f}, {33, -24.0f}, {66, -15.0f}, {100, -6.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sHeadsetSystemVolumeCurve[Volume::VOLCNT] = {
- {1, -30.0f}, {33, -26.0f}, {66, -22.0f}, {100, -18.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sDefaultVoiceVolumeCurve[Volume::VOLCNT] = {
- {0, -42.0f}, {33, -28.0f}, {66, -14.0f}, {100, 0.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sSpeakerVoiceVolumeCurve[Volume::VOLCNT] = {
- {0, -24.0f}, {33, -16.0f}, {66, -8.0f}, {100, 0.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sLinearVolumeCurve[Volume::VOLCNT] = {
- {0, -96.0f}, {33, -68.0f}, {66, -34.0f}, {100, 0.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sSilentVolumeCurve[Volume::VOLCNT] = {
- {0, -96.0f}, {1, -96.0f}, {2, -96.0f}, {100, -96.0f}
-};
-
-const VolumeCurvePoint
-ApmGains::sFullScaleVolumeCurve[Volume::VOLCNT] = {
- {0, 0.0f}, {1, 0.0f}, {2, 0.0f}, {100, 0.0f}
-};
-
-const VolumeCurvePoint *ApmGains::sVolumeProfiles[AUDIO_STREAM_CNT]
- [Volume::DEVICE_CATEGORY_CNT] = {
- { // AUDIO_STREAM_VOICE_CALL
- ApmGains::sDefaultVoiceVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sSpeakerVoiceVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sSpeakerVoiceVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_SYSTEM
- ApmGains::sHeadsetSystemVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sDefaultSystemVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sDefaultSystemVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sExtMediaSystemVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_RING
- ApmGains::sDefaultVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sSpeakerSonificationVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sDefaultVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sExtMediaSystemVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_MUSIC
- ApmGains::sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_ALARM
- ApmGains::sDefaultVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sSpeakerSonificationVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sDefaultVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sExtMediaSystemVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_NOTIFICATION
- ApmGains::sDefaultVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sSpeakerSonificationVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sDefaultVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sExtMediaSystemVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_BLUETOOTH_SCO
- ApmGains::sDefaultVoiceVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sSpeakerVoiceVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sDefaultVoiceVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_ENFORCED_AUDIBLE
- ApmGains::sHeadsetSystemVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sDefaultSystemVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sDefaultSystemVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sExtMediaSystemVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_DTMF
- ApmGains::sHeadsetSystemVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sDefaultSystemVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sDefaultSystemVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sExtMediaSystemVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_TTS
- // "Transmitted Through Speaker": always silent except on DEVICE_CATEGORY_SPEAKER
- ApmGains::sSilentVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sLinearVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sSilentVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sSilentVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_ACCESSIBILITY
- ApmGains::sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sSpeakerMediaVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sDefaultMediaVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sDefaultMediaVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_REROUTING
- ApmGains::sFullScaleVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sFullScaleVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sFullScaleVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sFullScaleVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
- { // AUDIO_STREAM_PATCH
- ApmGains::sFullScaleVolumeCurve, // DEVICE_CATEGORY_HEADSET
- ApmGains::sFullScaleVolumeCurve, // DEVICE_CATEGORY_SPEAKER
- ApmGains::sFullScaleVolumeCurve, // DEVICE_CATEGORY_EARPIECE
- ApmGains::sFullScaleVolumeCurve // DEVICE_CATEGORY_EXT_MEDIA
- },
-};
-
-//static
-float ApmGains::volIndexToAmpl(audio_devices_t device, const StreamDescriptor& streamDesc,
- int indexInUi)
-{
- Volume::device_category deviceCategory = Volume::getDeviceCategory(device);
- const VolumeCurvePoint *curve = streamDesc.getVolumeCurvePoint(deviceCategory);
-
- // the volume index in the UI is relative to the min and max volume indices for this stream type
- int nbSteps = 1 + curve[Volume::VOLMAX].mIndex -
- curve[Volume::VOLMIN].mIndex;
- int volIdx = (nbSteps * (indexInUi - streamDesc.getVolumeIndexMin())) /
- (streamDesc.getVolumeIndexMax() - streamDesc.getVolumeIndexMin());
-
- // find what part of the curve this index volume belongs to, or if it's out of bounds
- int segment = 0;
- if (volIdx < curve[Volume::VOLMIN].mIndex) { // out of bounds
- return 0.0f;
- } else if (volIdx < curve[Volume::VOLKNEE1].mIndex) {
- segment = 0;
- } else if (volIdx < curve[Volume::VOLKNEE2].mIndex) {
- segment = 1;
- } else if (volIdx <= curve[Volume::VOLMAX].mIndex) {
- segment = 2;
- } else { // out of bounds
- return 1.0f;
- }
-
- // linear interpolation in the attenuation table in dB
- float decibels = curve[segment].mDBAttenuation +
- ((float)(volIdx - curve[segment].mIndex)) *
- ( (curve[segment+1].mDBAttenuation -
- curve[segment].mDBAttenuation) /
- ((float)(curve[segment+1].mIndex -
- curve[segment].mIndex)) );
-
- float amplification = exp( decibels * 0.115129f); // exp( dB * ln(10) / 20 )
-
- ALOGVV("VOLUME vol index=[%d %d %d], dB=[%.1f %.1f %.1f] ampl=%.5f",
- curve[segment].mIndex, volIdx,
- curve[segment+1].mIndex,
- curve[segment].mDBAttenuation,
- decibels,
- curve[segment+1].mDBAttenuation,
- amplification);
-
- return amplification;
-}
-
-
-
AudioGain::AudioGain(int index, bool useInChannelMask)
{
mIndex = index;