如何进入工序是什么意思调大安卓手机声音?

mtk手机声音调大小_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
享专业文档下载特权
&赠共享文档下载特权
&10W篇文档免费专享
&每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
mtk手机声音调大小
你可能喜欢Android 4.4 音量调节流程分析(一) - 蜗牛慢慢 - 博客园
随笔 - 20, 文章 - 0, 评论 - 2, 引用 - 0
  最近在做Android Audio方面的工作,有需求是在调节Volume_Up_Key & Volume_Down_key时,Spearker or Headset每音阶的衰减变为3db左右。所以利用Source Insight分析Android源码中音量控制的流程,如有错误,欢迎指正,谢谢!  
  以下是调节音量的流程:
  Step_1.首先在调节机台Volume_Up_Key & Volume_Down_Key操作时,系统会调用到AudioManager.java中handleKeyUp & handleKeyDown函数,以 handleKeyDown函数为例:
1 public void handleKeyDown(KeyEvent event, int stream) {
int keyCode = event.getKeyCode();
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP:
/*KeyEvent 在KeyEvent.java中定义*/
case KeyEvent.KEYCODE_VOLUME_DOWN:
int flags = FLAG_SHOW_UI | FLAG_VIBRATE;
if (mUseMasterVolume) {
adjustMasterVolume(
keyCode == KeyEvent.KEYCODE_VOLUME_UP
? ADJUST_RAISE
: ADJUST_LOWER,
adjustSuggestedStreamVolume(
keyCode == KeyEvent.KEYCODE_VOLUME_UP
? ADJUST_RAISE
: ADJUST_LOWER,
       ... ...
  其中是否进入adjustMasterVolume 函数是通过mUseMasterVolume的值判断的,而mUseMasterVolume的值是在AudioManager的构造函数中定义,其值的大小如下:mUseMasterVolume&=&mContext.getResources().getBoolean(com.android.internal.R.bool.config_useMasterVolume),所以首先从系统的配置文件config.xml中查找config_useMasterVolume值的大小
  &bool name="config_useMasterVolume"&false&/bool&
  所以handleKeyDown中 switch语句中会选择进入adjustSuggestedStreamVolume函数。
public void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags) {
IAudioService service = getService();
if (mUseMasterVolume) {
service.adjustMasterVolume(direction, flags, mContext.getOpPackageName());
service.adjustSuggestedStreamVolume(direction, suggestedStreamType, flags,
mContext.getOpPackageName());
  ... ...11      }
  Step_2.在adjustSuggestedStreamVolume函数中首先会通过binder机制得到AudioService,并将音量控制过程转入到AudioService.java中。
public void adjustStreamVolume(int streamType, int direction, int flags,
String callingPackage) {
/*音量调大时,若要超过SafeMediaVolume时,系统会弹出对话框给予确认*/
if ((direction == AudioManager.ADJUST_RAISE) &&
!checkSafeMediaVolume(streamTypeAlias, aliasIndex + step, device)) {
Log.e(TAG, "adjustStreamVolume() safe volume index = "+oldIndex);
mVolumePanel.postDisplaySafeVolumeWarning(flags);
} else if (streamState.adjustIndex(direction * step, device)) {
sendMsg(mAudioHandler,
MSG_SET_DEVICE_VOLUME,
/*需要处理的Message值*/
SENDMSG_QUEUE,
streamState,
int index = mStreamStates[streamType].getIndex(device);
sendVolumeUpdate(streamType, oldIndex, index, flags);
/*通知上层更新Volume*/
  在adjustStreamVolume 中会通过sendMsg的方式来将调节音量的事件加入到消息列队SENDMSG_QUENE中,当轮寻到该Message时,系统会调用handleMessage函数来处理该Message,此时该处对应的Message为MSG_SET_DEVICE_VOLUME。
public void handleMessage(Message msg) {
switch (msg.what) {
case MSG_SET_DEVICE_VOLUME:
setDeviceVolume((VolumeStreamState) msg.obj, msg.arg1);
case MSG_SET_ALL_VOLUMES:
setAllVolumes((VolumeStreamState) msg.obj);
  ... ...
  可以发现当msg.what =& MSG_SET_DEVICE_VOLUME时,会进到setDeviceVolume函数中,继续往下分析:
private void setDeviceVolume(VolumeStreamState streamState, int device) {
// Apply volume
streamState.applyDeviceVolume(device);
// Apply change to all streams using this one as alias
     ... ...
// Post a persist volume msg
     ... ...
  applyDeviceVolume就是将音量Volume设置到对应的设备Device上,继续往下分析:
public void applyDeviceVolume(int device) {
if (isMuted()) {
index = 0;
} else if ((device & AudioSystem.DEVICE_OUT_ALL_A2DP) != 0 &&
mAvrcpAbsVolSupported) {
index = (mIndexMax + 5)/10;
index = (getIndex(device) + 5)/10;
AudioSystem.setStreamVolumeIndex(mStreamType, index, device);
  此处VolumeIndex就是对应UI界面调节音量时,音量所处在的位置下标。在AudioService.java中定义了每种音频流对应的Max-Index,在AudioManager.java中定义了每种音频流在第一次刷机后默认的Index。
  Step_3.此时得到音量的下标Index后,会调用AudioSystem.java中的setStreamVolumeIndex函数中来得到此时音量的放大倍数。通过JNI层调用到AudioSystem.cpp文件中的 setStreamVolumeIndex中。
1 status_t AudioSystem::setStreamVolumeIndex(audio_stream_type_t stream,
int index,
audio_devices_t device)
const sp&IAudioPolicyService&& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
return aps-&setStreamVolumeIndex(stream, index, device);
  setStreamVolumeIndex函数中比较简单,通过StrongPointer来与AudioPolicyService建立联系,将AudioSystem中的setStreamVolumeIndex操作移到aps中完成。下面进入到AudioPolicyService.cpp文件中的setStreamVolumeIndex继续分析:
1 status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream,
int index,
audio_devices_t device)
if (mpAudioPolicy-&set_stream_volume_index_for_device) {
return mpAudioPolicy-&set_stream_volume_index_for_device(mpAudioPolicy,
return mpAudioPolicy-&set_stream_volume_index(mpAudioPolicy, stream, index);
  Step_4.AudioPolicyService.cpp作为bn端,其对应的bp端为AudioPolicyManagerBase.cpp。在当前函数的if语句中判断AudioPolicyManagerBase.cpp文件中是否存在setStreamVolumeIndexForDevice函数,条件成立则会选择setStreamVolumeIndexForDevice作为函数入口端;否则选择setStreamVolumeIndex作为函数入口。现在进入AudioPolicyManagerBase.cpp中文件中完成最后的分析:
1 status_t AudioPolicyManagerBase::setStreamVolumeIndex(AudioSystem::stream_type stream,
int index,
audio_devices_t device)
// compute and apply stream volume on all outputs according to connected device
status_t status = NO_ERROR;
for (size_t i = 0; i & mOutputs.size(); i++) {
audio_devices_t curDevice =
getDeviceForVolume(mOutputs.valueAt(i)-&device());
if ((device == AUDIO_DEVICE_OUT_DEFAULT) || (device == curDevice)) {
status_t volStatus = checkAndSetVolume(stream, index, mOutputs.keyAt(i), curDevice);
if (volStatus != NO_ERROR) {
status = volS
继续调用checkAndSetVolume函数:
1 status_t AudioPolicyManagerBase::checkAndSetVolume(int stream,
int index,
audio_io_handle_t output,
audio_devices_t device,
int delayMs,
bool force)
// do not change actual stream volume if the stream is muted
// do not change in call volume if bluetooth is connected and vice versa
audio_devices_t checkedDevice = (device == AUDIO_DEVICE_NONE) ? mOutputs.valueFor(output)-&device() :
float volume = computeVolume(stream, index, checkedDevice);
17   mpClientInterface-&setStreamVolume((AudioSystem::stream_type)stream, volume, output, delayMs);/*将得到的volume应用到对应的output中*/
  在checkAndSetVolume中可以知道volume是通过computeVolume得到的。继续向下分析:
float AudioPolicyManagerBase::computeVolume(int stream,
int index,
audio_devices_t device)
volume = volIndexToAmpl(device, streamDesc, index);
  终于到了最后volIndexToAmpl,从函数名就可以知道该函数的作用是通过volIndex得到音量放大倍数。
float AudioPolicyManagerBase::volIndexToAmpl(audio_devices_t device, const StreamDescriptor& streamDesc,
int indexInUi)
device_category deviceCategory = getDeviceCategory(device);
const VolumeCurvePoint *curve = streamDesc.mVolumeCurve[deviceCategory];
// the volume index in the UI is relative to the min and max volume indices for this stream type
int nbSteps = 1 + curve[VOLMAX].mIndex -
curve[VOLMIN].mI
int volIdx = (nbSteps * (indexInUi - streamDesc.mIndexMin)) /
(streamDesc.mIndexMax - streamDesc.mIndexMin);
// find what part of the curve this index volume belongs to, or if it's out of bounds
int segment = 0;
if (volIdx & curve[VOLMIN].mIndex) {
// out of bounds
return 0.0f;
} else if (volIdx & curve[VOLKNEE1].mIndex) {
segment = 0;
} else if (volIdx & curve[VOLKNEE2].mIndex) {
segment = 1;
} else if (volIdx &= curve[VOLMAX].mIndex) {
segment = 2;
// 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 )
  其中curve代表在用设备(如SPEAKER、HEADSET & EARPIECE)播放音频流(如SYSTEM、MUSIC、ALARM、RING & TTS等)时的音量曲线,最后decibles & amplification就是我们需要求的值,其中decibles代表某一音节所对应的dB值,而amplification则是由dB值转化得到的音量放大倍数。这样整个音量调节过程到此就算完成了,具体的计算分析会放在后面继续分析。豆丁微信公众号
君,已阅读到文档的结尾了呢~~
android音量调整流程 HDMI音量控制修改,android音量调节流程,android hdmi输出,android hdmi,android hdmi设置,android hdmi 分辨率,android手机 hdmi输出,android hdmi spdif,android hdmi 开发,android hdmi cec
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
android音量调整流程 HDMI音量控制修改
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='http://www.docin.com/DocinViewer--144.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口手机系统声音大小怎么设置?_百度知道
手机系统声音大小怎么设置?
1,打开安卓手机的设置应用,进入手机的设置应用界面,。2,在设置应用中,点击“声音和振动选项”。3,点击进入音量调节。具体步骤下图所示:1,打开安卓手机的设置应用,进入手机的设置应用界面。2,在设置应用中,点击“声音和振动选项”。3,点击进入音量调节。参考资料.米柚[引用时间]
采纳率:99%
为您推荐:
其他类似问题
您可能关注的内容
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。声音大小调节 6.13
投诉建议:
千万流量共享 百度高权重排名
软件大小: 2.14M
软件厂商:
声音大小调节
软件语言: 简体中文
软件授权: 免费
软件评级:
更新时间:
编辑推荐:
声音大小调节6.13应用截图
声音大小调节会根据所听到的周围环境声音分贝,自动计算出完美的铃声音量,一切都不需要手工设置,当到达某一个环境中,它能够自动进入一种声音模式,在吵闹的时候提高铃声的音量,而在安静的环境中自动分配较低的铃声音量。
声音大小调节功能:
1、自动根据周边环境调节铃声声音大小
2、自动分析声音分贝
3、无需手工设置即可让铃声自适应环境声音大小调节 6.13 更新内容增加声音分贝的分析能力。
*应用权限:
允许应用程序访问网络连接
允许应用程序打开系统窗口,显示其他应用程序
允许应用程序获取当前或最近运行的应用
允许应用程序写入外部存储,如SD卡上写文件
允许应用程序访问Wi-Fi网络状态信息
允许应用程序录制音频
允许应用程序获取网络信息状态
允许应用程序读取电话状态
允许应用程序读取或写入系统设置
允许应用程序读取扩展存储器
今日更新推荐
同类软件下载排行
热门关键词}

我要回帖

更多关于 装修工序流程 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信