Android 10.0 audio模块支持多个app同时录音的功能

1.概述

在10.0的定制化开发中,由于有多个app的audio部分需要进行录音功能,所以要求系统framework需要同时支持多个app同时录音满足需求,这就需要跟相关代码来实现这个功能

2.支持多个app同时录音的核心代码

主要代码为:
frameworks/av/services/audiopolicy/service/AudioPolicyService.cpp

3.支持多个app同时录音的核心代码分析及功能实现

3.1支持多个app同时录音的代码分析

通过查阅10.0相关代码发现默认支持多个app同时录音,但是经过测试发现还是有一部分问题的,

两个app虽然能同时使用 AudioRecord, 但是后一个应用调用后能正常拿到音频数据, 前一个应用就拿不到音频数据

查阅资料发现 具体处理是在AudioPolicyService.cpp中

void AudioPolicyService::updateUidStates_l()
{
//    Go over all active clients and allow capture (does not force silence) in the
//    following cases:
//    Another client in the same UID has already been allowed to capture
//    OR The client is the assistant
//        AND an accessibility service is on TOP or a RTT call is active
//               AND the source is VOICE_RECOGNITION or HOTWORD
//        OR uses VOICE_RECOGNITION AND is on TOP
//               OR uses HOTW

猜你喜欢

转载自blog.csdn.net/baidu_41666295/article/details/125530777