音量压低处理流程

开始

通过申请临时DUCK焦点可以压低其他在播放的音源,如源码中的注释,不会暂停其他在播放的音源,而是降低输出,在车载情景下,一般在地图导航或者语音播报的情景下会申请这个焦点。

// AudioManager.java
/**
 * Used to indicate a temporary request of audio focus, anticipated to last a short
 * amount of time, and where it is acceptable for other audio applications to keep playing
 * after having lowered their output level (also referred to as "ducking").
 * Examples of temporary changes are the playback of driving directions where playback of music
 * in the background is acceptable.
 * @see OnAudioFocusChangeListener#onAudioFocusChange(int)
 * @see #requestAudioFocus(OnAudioFocusChangeListener, int, int)
 */
public static final int AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK = 3;

我们在源码中进行全局搜索,应该是在/frameworks/base/services/core/java/com/android/server/audio/PlaybackActivityMonitor.java,我们接着看这个类

流程

下面流程基于aosp9
在这里插入图片描述

通过AudioManager申请临时DUCK焦点后,最终压低声音是由具体的Player进行压低的,通过native_applyVolumeShaper()实现。

具体细节待补充…

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值