Android Framework源码解读 - Audio - SoundTrigger(1) - AIDL

SoundTrigger语音识别架构是Android5.0才引入,在Android7.0逐步完善。

官方介绍:https://source.android.google.cn/devices/audio/sound-trigger

The Sound Trigger feature provides apps with the ability to listen for certain acoustic events, like hotwords, in a low-power and privacy-sensitive manner. Example use cases of Sound Trigger are Assistant and Now Playing.

应用场景主要有 语音助手(VIA) 或者 唤醒词(HOTWORD),本文主要关注的是右边: 唤醒词方案。至于VIA比较全的说明可参考:https://source.android.google.cn/devices/automotive/voice/voice_interaction_guide

The function of the Sound Trigger stack is to deliver discrete events that represent acoustic, trigger events. In most cases, the Sound Trigger stack does not deal with audio. Upon receipt of the trigger events, apps get access to the actual audio stream, surrounding the time of the events, by opening an AudioRecord object via the Audio framework. The Sound Trigger HAL APIs provide a handle with the triggered event that is used with the Audio Framework. Hence, since the Sound Trigger HAL and Audio HAL are connected under the hood, they typically share a process.

粗体字节部分是关键点,意思就是soundtrigger主要负责的是声学(acoustic)唤醒词的识别,识别后会触发相应的events给到上层。它不负责处理后续音频数据,应用层应该通过AudioRecord的方式来读取后续的音频数据。另外如之前篇介绍:Android Framework源码解读 - Audio - audioserver启动流程(2) - HIDL ,soundtrigger hal层的加载是通过auido hal层加载带入的,因此它们处于同一个进程中,即android.hardware.audio@2.0-service。

官方的sound-trigger的其他说明,看起来也还是不太好理解,不够细节,所以接下来还是继续以源码解读方式来揭开SoundTrigger的面纱。

三大部分

1、SoundTriggerHwService

/frameworks/av/media/audioserver/main_audioserver.cpp  包含 SoundTriggerHwService::instantiate();这部分在之前的文章Android Framework源码解读 - Audio - audioserver启动流程(1),已经有提到,这里再回顾一下:

audioserver进程(main_audioserver.cpp)的main函数里面创建了SoundTriggerHwService, ./frameworks/av/services/soundtrigger/SoundTriggerHwService.cpp

主要工作:1、创建共享内存 new MemoryDealer(1024*1024, “SoundTriggerHwService”) ;  2、对接HAL层connectModule(“primary”);

./frameworks/av/services/soundtrigger/SoundTriggerHalInterface.h, ./frameworks/av/services/soundtrigger/SoundTriggerHalHidl.cpp

SoundTriggerHalHidl类是SoundTriggerHalInterface具体的实现类。

2、SoundTrigge

  • 3
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值