[RK3288][Android6.0] 调试笔记 --- Audio的Voice Call无法静音问题

Platform: Rockchip
OS: Android 6.0
Kernel: 3.10.92

现象
AudioService中把音量设置到最小,理论上speaker应该听不到声音,但是依然还有。

分析
根据上一篇音量设置文章,参考:http://blog.csdn.net/kris_fei/article/details/72957142
这时对应的curve是
const VolumeCurvePoint Gains::sSpeakerVoiceVolumeCurve[Volume::VOLCNT] = {
    {1, -24.0f}, {33, -16.0f}, {66, -8.0f}, {100, 0.0f}
};

当audio service设置index为最小(index = 1)时,
float Gains::volIndexToDb(Volume::device_category deviceCategory,
                          const StreamDescriptor& streamDesc,
                          int indexInUi)
{
.....
	//volId计算出来是0
	int volIdx = (nbSteps * (indexInUi - streamDesc.getVolumeIndexMin())) /
		(streamDesc.getVolumeIndexMax() - streamDesc.getVolumeIndexMin());
	//curve[Volume::VOLKNEE1].mIndex为0,因此不会返回VOLUME_MIN_DB
    if (volIdx < curve[Volume::VOLMIN].mIndex) {         // out of bounds
        return VOLUME_MIN_DB;
    } 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 { 
        return 0.0f;
    }
......
}

解决方法
kris@:~/rk3288/frameworks/av/services/audiopolicy/enginedefault$ g df
diff --git a/services/audiopolicy/enginedefault/src/Gains.cpp b/services/audiopolicy/enginedefault/src/Gains.cpp
index df853db..49555aa 100644
--- a/services/audiopolicy/enginedefault/src/Gains.cpp
+++ b/services/audiopolicy/enginedefault/src/Gains.cpp
@@ -95,7 +95,7 @@ Gains::sDefaultVoiceVolumeCurve[Volume::VOLCNT] = {
 
 const VolumeCurvePoint
 Gains::sSpeakerVoiceVolumeCurve[Volume::VOLCNT] = {
-    {0, -24.0f}, {33, -16.0f}, {66, -8.0f}, {100, 0.0f}
+    {1, -24.0f}, {33, -16.0f}, {66, -8.0f}, {100, 0.0f}
 };
 

你可能感兴趣的:(子类__Audio)