summaryrefslogtreecommitdiffstats
path: root/services/audiopolicy/enginedefault
diff options
context:
space:
mode:
Diffstat (limited to 'services/audiopolicy/enginedefault')
-rwxr-xr-xservices/audiopolicy/enginedefault/src/Engine.cpp5
-rwxr-xr-xservices/audiopolicy/enginedefault/src/Engine.h6
-rw-r--r--services/audiopolicy/enginedefault/src/Gains.cpp30
-rw-r--r--services/audiopolicy/enginedefault/src/Gains.h9
4 files changed, 32 insertions, 18 deletions
diff --git a/services/audiopolicy/enginedefault/src/Engine.cpp b/services/audiopolicy/enginedefault/src/Engine.cpp
index 26a0d09..50f1609 100755
--- a/services/audiopolicy/enginedefault/src/Engine.cpp
+++ b/services/audiopolicy/enginedefault/src/Engine.cpp
@@ -63,13 +63,14 @@ status_t Engine::initCheck()
return (mApmObserver != NULL) ? NO_ERROR : NO_INIT;
}
-float Engine::volIndexToAmpl(Volume::device_category category, audio_stream_type_t streamType,
+float Engine::volIndexToDb(Volume::device_category category, audio_stream_type_t streamType,
int indexInUi)
{
const StreamDescriptor &streamDesc = mApmObserver->getStreamDescriptors().valueAt(streamType);
- return Gains::volIndexToAmpl(category, streamDesc, indexInUi);
+ return Gains::volIndexToDb(category, streamDesc, indexInUi);
}
+
status_t Engine::initStreamVolume(audio_stream_type_t stream, int indexMin, int indexMax)
{
ALOGV("initStreamVolume() stream %d, min %d, max %d", stream , indexMin, indexMax);
diff --git a/services/audiopolicy/enginedefault/src/Engine.h b/services/audiopolicy/enginedefault/src/Engine.h
index f44556c..56a4748 100755
--- a/services/audiopolicy/enginedefault/src/Engine.h
+++ b/services/audiopolicy/enginedefault/src/Engine.h
@@ -101,10 +101,10 @@ private:
{
return mPolicyEngine->initializeVolumeCurves(isSpeakerDrcEnabled);
}
- virtual float volIndexToAmpl(Volume::device_category deviceCategory,
+ virtual float volIndexToDb(Volume::device_category deviceCategory,
audio_stream_type_t stream,int indexInUi)
{
- return mPolicyEngine->volIndexToAmpl(deviceCategory, stream, indexInUi);
+ return mPolicyEngine->volIndexToDb(deviceCategory, stream, indexInUi);
}
private:
Engine *mPolicyEngine;
@@ -141,7 +141,7 @@ private:
audio_devices_t getDeviceForStrategy(routing_strategy strategy) const;
audio_devices_t getDeviceForInputSource(audio_source_t inputSource) const;
- float volIndexToAmpl(Volume::device_category category,
+ float volIndexToDb(Volume::device_category category,
audio_stream_type_t stream, int indexInUi);
status_t initStreamVolume(audio_stream_type_t stream, int indexMin, int indexMax);
void initializeVolumeCurves(bool isSpeakerDrcEnabled);
diff --git a/services/audiopolicy/enginedefault/src/Gains.cpp b/services/audiopolicy/enginedefault/src/Gains.cpp
index a684fdd..78f2909 100644
--- a/services/audiopolicy/enginedefault/src/Gains.cpp
+++ b/services/audiopolicy/enginedefault/src/Gains.cpp
@@ -197,10 +197,10 @@ const VolumeCurvePoint *Gains::sVolumeProfiles[AUDIO_STREAM_CNT]
};
//static
-float Gains::volIndexToAmpl(audio_devices_t device, const StreamDescriptor& streamDesc,
- int indexInUi)
+float Gains::volIndexToDb(Volume::device_category deviceCategory,
+ 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
@@ -212,7 +212,7 @@ float Gains::volIndexToAmpl(audio_devices_t device, const StreamDescriptor& stre
// 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;
+ return VOLUME_MIN_DB;
} else if (volIdx < curve[Volume::VOLKNEE1].mIndex) {
segment = 0;
} else if (volIdx < curve[Volume::VOLKNEE2].mIndex) {
@@ -220,7 +220,7 @@ float Gains::volIndexToAmpl(audio_devices_t device, const StreamDescriptor& stre
} else if (volIdx <= curve[Volume::VOLMAX].mIndex) {
segment = 2;
} else { // out of bounds
- return 1.0f;
+ return 0.0f;
}
// linear interpolation in the attenuation table in dB
@@ -231,17 +231,25 @@ float Gains::volIndexToAmpl(audio_devices_t device, const StreamDescriptor& stre
((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",
+ ALOGVV("VOLUME vol index=[%d %d %d], dB=[%.1f %.1f %.1f]",
curve[segment].mIndex, volIdx,
curve[segment+1].mIndex,
curve[segment].mDBAttenuation,
decibels,
- curve[segment+1].mDBAttenuation,
- amplification);
+ curve[segment+1].mDBAttenuation);
+
+ return decibels;
+}
- return amplification;
+
+//static
+float Gains::volIndexToAmpl(Volume::device_category deviceCategory,
+ const StreamDescriptor& streamDesc,
+ int indexInUi)
+{
+ return Volume::DbToAmpl(volIndexToDb(deviceCategory, streamDesc, indexInUi));
}
+
+
}; // namespace android
diff --git a/services/audiopolicy/enginedefault/src/Gains.h b/services/audiopolicy/enginedefault/src/Gains.h
index b5601ca..7620b7d 100644
--- a/services/audiopolicy/enginedefault/src/Gains.h
+++ b/services/audiopolicy/enginedefault/src/Gains.h
@@ -29,8 +29,13 @@ class StreamDescriptor;
class Gains
{
public :
- static float volIndexToAmpl(audio_devices_t device, const StreamDescriptor& streamDesc,
- int indexInUi);
+ static float volIndexToAmpl(Volume::device_category deviceCategory,
+ const StreamDescriptor& streamDesc,
+ int indexInUi);
+
+ static float volIndexToDb(Volume::device_category deviceCategory,
+ const StreamDescriptor& streamDesc,
+ int indexInUi);
// default volume curve
static const VolumeCurvePoint sDefaultVolumeCurve[Volume::VOLCNT];