1.通过调节音量曲线实现
a.查看拍照时快门声音的音频流log信息:
10-06 21:55:10.565 875 875 D AS.AudioService: adjustStreamVolume() stream=3, dir=0, flags=4112, caller=android
10-06 21:55:11.033 875 5084 D AS.AudioService: Volume controller visible: false
10-06 21:55:11.038 875 2273 D AS.AudioService: forceVolumeControlStream(-1)
10-06 21:55:11.143 29655 29655 I CAM_PhotoModule: takePicture start!
结合代码可以看出stream3对应的是music,在audio_policy_engine_stream_volumes.xml文件调节对应的音量曲线
device/sprd/mpool/module/audio/msoc/sharkle/system/etc/parameter-framework/audio_policy_engine_stream_volumes.xml
52
53 music
54 0
55 7
56
57 1,-3000
58 33,-2600
59 66,-2200
60 100,-1800
61
62
63 1,-2400
64 33,-1800
65 66,-1200
66 100,-600
67
68
69
70
71
72
调节方式如下图所示:
b.如果强制快门声音打开,则需要调节enforced_audible的音量曲线:
强制快门宏开关:
frameworks/base/core/res/res/values/config.xml
true
149
150 enforced_audible
151 0
152 7
153
154 1,-2400
155 33,-1800
156 66,-1200
157 100,-600
158
159
160 1,-2400
161 33,-1800
162 66,-1200
163 100,-600
164
c.若有些stream模式下面没有对应的point参数设置,则为设置的默认参数,需要在audio_policy_engine_default_stream_volumes.xml文件中调节
代码在ring模式下没有对应的point参数,无法调节音量曲线
<name>ring</name>
<indexMin>0</indexMin>
<indexMax>7</indexMax>
<volume deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_DEVICE_CATEGORY_HEADSET_VOLUME_CURVE"/>
<volume deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_DEVICE_CATEGORY_SPEAKER_VOLUME_CURVE"/>
<volume deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_DEVICE_CATEGORY_EARPIECE_VOLUME_CURVE"/>
<volume deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_DEVICE_CATEGORY_EXT_MEDIA_VOLUME_CURVE"/>
<volume deviceCategory="DEVICE_CATEGORY_HEARING_AID" ref="DEFAULT_HEARING_AID_VOLUME_CURVE"/>
</volumeGroup>
实际上采用的是默认参数 DEFAULT_DEVICE_CATEGORY_HEADSET_VOLUME_CURVE,需要在如下目录文件修改
device/sprd/mpool/module/audio/msoc/sharkle/system/etc/parameter-framework/audio_policy_engine_default_stream_volumes.xml
ring
<reference name="DEFAULT_DEVICE_CATEGORY_HEADSET_VOLUME_CURVE">
<!--Default Volume Curve -->
-
<point>1,-4950</point>
-
<point>33,-3350</point>
-
<point>66,-1700</point>
-
<point>100,0</point>
-
<point>1,-2400</point>
-
<point>33,-1800</point>
-
<point>66,-1200</point>
-
<point>100,-0</point>
2.通过修改音频源文件实现
如果通过调节音量曲线没有效果或者效果不满意,可能是音频源自身问题,需要更新音频源
导出frameworks/base/data/sounds/effects/ogg目录下的camera_click.ogg资源文件
通过Audacity软件增强音频源文件,然后再导入ogg目录下。
此方式也可用于自定义快门声音,替换ogg音频源文件即可。