本文所写内容是在高通芯片平台相关代码基础上学习整理汇总,如有描述不当之处,欢迎指正!

1、SoundTrigger注册唤醒监听事件回调流程(SoundTrigger HAL层到ADSP层,不包括FWK层)

//(1)SoundTriggerSession 回调
vendor/qcom/opensource/audio-hal/st-hal/SoundTriggerSession.cpp
void SoundTriggerSession::GetRecognitionCallback(recognition_callback_t *callback)*callback = rec_callback_;//(2)StartRecognition()接口,关联到 callback
int SoundTriggerSession::StartRecognition(const struct sound_trigger_recognition_config *config,recognition_callback_t callback,void *cookie,uint32_t version)rec_callback_ = callback;//(3)在pal_callback()中调用callback()将存放在sound_trigger_recognition_event 中的数据传递fwkint SoundTriggerSession::pal_callback(pal_stream_handle_t *stream_handle,uint32_t event_id,uint32_t *event_data,uint32_t event_size,uint64_t cookie)struct sound_trigger_recognition_event *st_event = nullptr;
recognition_callback_t callback;
session->GetRecognitionCallback(&callback);callback(st_event, session->GetCookie());//(4)在SoundTriggerDevice()中调用SoundTriggerSession::StartRecognition()
vendor/qcom/opensource/audio-hal/st-hal/SoundTriggerDevice.cpp
static int stdev_start_recognition(const struct sound_trigger_hw_device *dev,sound_model_handle_t sound_model_handle,const struct sound_trigger_recognition_config *config,recognition_callback_t callback,void *cookie)ATRACE_BEGIN("sthal: stdev_start_recognition");
status = st_session->StartRecognition(config, callback, cookie, hw_properties_extended.header.version);//(5)在SoundTriggerDevice::Init()中进行接口初始化
int SoundTriggerDevice::Init(hw_device_t **device, const hw_module_t *module)STHAL_DBG(LOG_TAG, "Register LSM HIDL service");device_->start_recognition = stdev_start_recognition;device_->stop_recognition = stdev_stop_recognition;//(6)SoundTriggerHw开启监听,调用SoundTriggerDevice::start_recognition()
hardware/interfaces/soundtrigger/2.3/default/SoundTriggerHw.cpp
Return<int32_t> SoundTriggerHw::startRecognition(int32_t modelHandle, const V2_0::ISoundTriggerHw::RecognitionConfig& config,const sp<V2_0::ISoundTriggerHwCallback>& /* callback */, int32_t /* cookie */)ret = mHwDevice->start_recognition(mHwDevice, client->getHalHandle(), halConfig,recognitionCallback_, client.get());//(7)SoundTriggerDetector 调用startRecognition()注册回调给到HAL层
frameworks/base/media/java/android/media/soundtrigger/SoundTriggerDetector.java
public boolean startRecognition(@RecognitionFlags int recognitionFlags)
try {status = mSoundTriggerSession.startRecognition(mSoundModel,mRecognitionCallback, new RecognitionConfig(captureTriggerAudio,allowMultipleTriggers, null, null, audioCapabilities),runInBatterySaver);} catch (RemoteException e) {return false;}/*** This class should be constructed by the {@link SoundTriggerManager}.* @hide*/SoundTriggerDetector(ISoundTriggerSession soundTriggerSession,@NonNull GenericSoundModel soundModel,@NonNull Callback callback, @Nullable Handler handler) {mSoundTriggerSession = soundTriggerSession;mSoundModel = soundModel;mCallback = callback;if (handler == null) {mHandler = new MyHandler();} else {mHandler = new MyHandler(handler.getLooper());}mRecognitionCallback = new RecognitionCallback();}事件上报时有两个结构体,一个是sound_trigger_recognition_config,这个是sound_trigger_recognition配置相关的;
还有一个sound_trigger_recognition_event,这个的英文注释如下:Generic recognition event sent via recognition callback。
prebuilts/vndk/v32/arm/include/system/media/audio/include/system/sound_trigger.h
/** configuration for sound trigger capture session passed to start_recognition()*/struct sound_trigger_recognition_config {audio_io_handle_t    capture_handle;    /* IO handle that will be used for capture.N/A if capture_requested is false */audio_devices_t      capture_device;    /* input device requested for detection capture */bool                 capture_requested; /* capture and buffer audio for this recognitioninstance */unsigned int         num_phrases;   /* number of key phrases recognition extras */struct sound_trigger_phrase_recognition_extra phrases[SOUND_TRIGGER_MAX_PHRASES];/* configuration for each key phrase */unsigned int        data_size;         /* size of opaque capture configuration data */unsigned int        data_offset;       /* offset of opaque data start from start of this struct(e.g sizeof struct sound_trigger_recognition_config) */};Generic recognition event sent via recognition callbackstruct __attribute__((aligned(8))) sound_trigger_recognition_event {int                              status;            /* recognition status e.g.RECOGNITION_STATUS_SUCCESS */sound_trigger_sound_model_type_t type;              /* event type, same as sound model type.e.g. SOUND_MODEL_TYPE_KEYPHRASE */sound_model_handle_t             model;             /* loaded sound model that triggered theevent */bool                             capture_available; /* it is possible to capture audio from thisutterance buffered by theimplementation */int                              capture_session;   /* audio session ID. framework use */int                              capture_delay_ms;  /* delay in ms between end of modeldetection and start of audio availablefor capture. A negative value is possible(e.g. if key phrase is also available forcapture */int                              capture_preamble_ms; /* duration in ms of audio capturedbefore the start of the trigger.0 if none. */bool                             trigger_in_data; /* the opaque data is the capture ofthe trigger sound */audio_config_t                   audio_config;        /* audio format of either the trigger inevent data or to use for capture of therest of the utterance */unsigned int                     data_size;         /* size of opaque event data */unsigned int                     data_offset;       /* offset of opaque data start from start ofthis struct (e.g sizeof structsound_trigger_phrase_recognition_event) */};

SoundTriggerDetector调用startRecognition()时将事件监听回调注册到SoundTriggerHal层。

2、高通芯片AudioReach架构芯片平台ADSP层唤醒事件上报流程

唤醒上报事件代码时序(高通AudioReach架构芯片平台)(1)唤醒模块代码上报唤醒事件
capi_wakeup_raise_event_to_dsp_client()me_ptr->cb_info.event_cb(me_ptr->cb_info.event_context,CAPI_EVENT_DATA_TO_DSP_CLIENT_V2, &event_info)CAPI_EVENT_DATA_TO_DSP_CLIENT_V2 = 15(2)capi的callback()回调接口处理此事件消息
gen_topo_capi_cb_handler.c
gen_topo_capi_callback_base(gen_topo_module_t *module_ptr,capi_event_id_t    id,capi_event_info_t *event_info_ptr)switch (id)case CAPI_EVENT_DATA_TO_DSP_CLIENT:case CAPI_EVENT_DATA_TO_DSP_CLIENT_V2:return ar_result_to_capi_err(topo_ptr->topo_to_cntr_vtable_ptr->handle_capi_event(module_ptr, id, event_info_ptr));ADSP.HT.5.8/adsp_proc/avs/fwk/spf/containers/spl_cntr/core/src/spl_cntr.c.handle_capi_event                           = spl_cntr_handle_capi_event,(3)调用spf框架的spl_cntr_handle_capi_event()
ADSP.HT.5.8/adsp_proc/avs/fwk/spf/containers/spl_cntr/core/src/spl_cntr_event_util.c
ar_result_t spl_cntr_handle_capi_event(gen_topo_module_t *module_ptr,capi_event_id_t    event_id,capi_event_info_t *event_info_ptr){spl_cntr_t *me_ptr = (spl_cntr_t *)GET_BASE_PTR(spl_cntr_t, topo, module_ptr->topo_ptr);ar_result_t result = AR_EOK;result = cu_handle_capi_event(&me_ptr->cu, &module_ptr->gu, event_id, event_info_ptr);return result;}cu_handle_capi_event()switch (event_id)case CAPI_EVENT_DATA_TO_DSP_CLIENT_V2:{result |= cu_handle_event_data_to_dsp_client_v2_topo_cb(cu_ptr, module_ptr, event_info_ptr);break;}(4)路由到spf框架的cu_handle_event_data_to_dsp_client_v2_topo_cb()接口
ADSP.HT.5.8/adsp_proc/avs/fwk/spf/containers/cmn/container_utils/core/src/cu_utils_island.c
/* Topo callback to handle module event to DSP client v2 */ar_result_t cu_handle_event_data_to_dsp_client_v2_topo_cb(cu_base_t *        cu_ptr,gu_module_t *      module_ptr,capi_event_info_t *event_info_ptr)capi_event_data_to_dsp_client_v2_t *payload_ptr =(capi_event_data_to_dsp_client_v2_t *)(event_info_ptr->payload.data_ptr);gpr_cmd_alloc_ext_v2_t args;args.heap_index    = dest_address.a.gpr_heap_index;args.src_domain_id = dest_address.a.dest_domain_id;args.dst_domain_id = dest_address.a.src_domain_id;args.src_port      = module_ptr->module_instance_id;args.dst_port      = dest_address.a.src_port;args.token         = payload_ptr->token;args.opcode        = APM_EVENT_MODULE_TO_CLIENT;args.payload_size  = sizeof(apm_module_event_t) + payload_ptr->payload.actual_data_len;args.client_data   = 0;args.ret_packet    = &event_packet_ptr;result             = __gpr_cmd_alloc_ext_v2(&args);//调用gpr接口发送gpr消息给到client端result = __gpr_cmd_async_send(event_packet_ptr);(5)调用gpr接口,为gpr消息申请分配对应的内存大小,
分配原则:先从静态内存池分配,静态分配失败,再从动态内存分配,两者都失败,上报内存分配失败。
ADSP.HT.5.8/adsp_proc/gpr/core/src/gpr_drv_island.c
uint32_t __gpr_cmd_alloc_ext_v2(gpr_cmd_alloc_ext_v2_t *args)rc = __gpr_cmd_alloc_v2(args->payload_size, args->heap_index, &new_packet);uint32_t __gpr_cmd_alloc_v2(uint32_t alloc_size, gpr_heap_index_t heap_index, gpr_packet_t **ret_packet)new_packet = (gpr_packet_t *)gpr_memq_alloc(block);// If packet couldnt not be allocated in static pool, check dynamic poolgpr_allocate_dynamic_packet(&new_packet, packet_size);

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/news/913914.shtml
繁体地址,请注明出处:http://hk.pswp.cn/news/913914.shtml
英文地址,请注明出处:http://en.pswp.cn/news/913914.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

OSPF实验以及核心原理全解

OSPF&#xff08;Open Shortest Path First&#xff0c;开放式最短路径优先&#xff09;是一种基于链路状态的内部网关协议&#xff08;IGP&#xff09;&#xff0c;广泛应用于中大型网络中。它通过维护网络拓扑信息&#xff0c;使用 SPF&#xff08;最短路径优先&#xff09;算…

Using Spring for Apache Pulsar:Transactions

本节介绍Spring for Apache Pulsar如何支持事务。OverviewSpring for Apache Pulsar事务支持是基于Spring Framework提供的事务支持构建的。在高层&#xff0c;事务资源向事务管理器注册&#xff0c;事务管理器反过来处理注册资源的事务状态&#xff08;提交、回滚等&#xff0…

在Ubuntu上从零开始编译并运行Home Assistant源码并集成HACS与小米开源的Ha Xiaomi Home

目录1. 前言&&叠甲2. 使用的环境3. 相关链接4. 前期步骤4.1 安装路径提前说明4.2 Ubuntu 相关依赖安装4.3 Python源码编译安装4.3.1 编译安装4.3.2 换源4.3.3 环境变量5. 构建Home Assistant源码5.1 clone源码5.2 创建虚拟Python环境5.3 安装项目依赖5.4 安装项目5.5 运…

【实习篇】之Http头部字段之Disposition介绍

Http头部字段之DispositionDisposition头部字段介绍RFC规范介绍RFC 6266与RFC 2047实习的时候公司将一个某个关于下载的Bug交给了我来修&#xff0c;看了代码和日志后发现是Disposition字段的规范兼容性惹的锅&#xff0c;因为有些协议使用的是老协议&#xff0c;我们的项目没有…

VM文件管理与Vi/vim操作

[rootlocalhost /]# sudo mkdir /opt [rootlocalhost /]# sudo mkdir /opt/tmp [rootlocalhost /]# sudo touch /opt/tmp/a.txt [rootlocalhost /]# ls /opt/tmp/ a.txt [rootlocalhost /]# 3.步骤1&#xff1a;创建文件并插入日期时间vi /tmp/newfile在vi编辑器中输入以下命令…

【Android】安卓四大组件之内容提供者(ContentProvider):从基础到进阶

你手机里的通讯录&#xff0c;存储了所有联系人的信息。如果你想把这些联系人信息分享给其他App&#xff0c;就可以通过ContentProvider来实现。。 一、什么是 ContentProvider ‌ContentProvider‌ 是 Android 四大组件之一&#xff0c;负责实现‌跨应用程序的数据共享与访问…

Vue-19-前端框架Vue之应用基础组件通信(二)

文章目录 1 v-model(父子相传)1.1 App.vue1.2 Father.vue1.2.1 v-model用在html标签上1.2.2 v-model用在html标签上(本质写法)1.2.3 v-model用在组件标签上1.2.4 v-model用在组件标签上(本质写法)1.3 MyInput(自定义的组件)1.4 修改modelValue1.4.1 Father.vue1.4.2 MyInput.vu…

宝塔下载pgsql适配spring ai

1.宝塔安装pgvector 1.先去github下载pgvectorpgvector/pgvector: Open-source vector similarity search for Postgres 2.把压缩包上传到系统文件的/temp下解压&#xff0c;重命名文件名为pgvector&#xff0c;之后命令操作 cd /tmp cd pgvector export PG_CONFIG/www/serv…

RK3568项目(八)--linux驱动开发之基础外设(上)

目录 一、引言 二、准备工作 ------>2.1、驱动加载/卸载命令 三、字符设备驱动开发 ------>3.1、驱动模块的加载和卸载 ------>3.2、外部模块编译模板 Makefile ------>3.3、cdev 四、LED驱动 ------>4.1、原理图 ------>4.2、驱动 五、设备树 -…

BUUCTF在线评测-练习场-WebCTF习题[GXYCTF2019]BabySQli1-flag获取、解析

解题思路打开靶场&#xff0c;题目提示是sql注入输入数据&#xff0c;判断下闭合11123报错&#xff1a;Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 1 at line 1报错提示…

“AI 曼哈顿计划”:科技竞赛还是人类挑战?

美国国会下属的经济与安全审查委员会已将“推动建立并资助一项堪比曼哈顿计划的通用人工智能研发项目”列为其对国会的核心建议之一&#xff0c;明确显示出对AI竞赛战略意义的高度重视。与此同时&#xff0c;美国能源部在近几个月中多次公开将人工智能的突破比作“下一场曼哈顿…

音频信号的预加重:提升语音清晰度

一、预加重介绍预加重是一种信号处理技术&#xff0c;主要用于增强音频信号中的高频成分。由于人类语音的频谱特性&#xff0c;尤其是在辅音和音调的表达上&#xff0c;高频成分对于语音的清晰度至关重要。然而&#xff0c;在录音和传输过程中&#xff0c;这些高频成分往往会受…

WebSocket实战:实现实时聊天应用 - 双向通信技术详解

目录一、WebSocket&#xff1a;实时通信的"高速公路"1.1 HTTP的短板&#xff1a;永远的"单相思"1.2 WebSocket的优势&#xff1a;真正的"双向对话"二、30分钟搭建聊天服务器2.1 环境准备2.2 WebSocket配置类2.3 核心消息处理器三、前端实现&…

宏集案例 | 基于CODESYS的自动化控制系统,开放架构 × 高度集成 × 远程运维

​​案例概况客户&#xff1a;MACS Sterilisationsanlagen GmbH&#xff08;Ermafa Environmental Technologies GmbH 旗下&#xff09; 应用场景&#xff1a;医疗与感染性废弃物的无害化处理控制系统应用产品&#xff1a;宏集Berghof高性能控制器设备&#xff08;一&#xff0…

学习JNI 二

创建一个名为Learn1项目&#xff08;Android Studio&#xff09;。一、项目结构二、配置 build.gradlebuild.gradle.kts(:app)plugins {alias(libs.plugins.android.application)alias(libs.plugins.jetbrains.kotlin.android) }android {namespace "com.demo.learn1&quo…

基于Spring Boot+Vue的DIY手工社预约管理系统(Echarts图形化、腾讯地图API)

2.10 视频课程管理功能实现2.11手工互动&#xff08;视频弹幕&#xff09;2.8预约设置管理功能实现&#x1f388;系统亮点&#xff1a;Echarts图形化、腾讯地图API&#xff1b;文档包含功能结构图、系统架构图、用例图、实体属性图、E-R图。一.系统开发工具与环境搭建1.系统设计…

leetcode 每日一题 1353. 最多可以参加的会议数目

更多技术访问 我的个人网站 &#xff08;免费服务器&#xff0c;没有80/443端口&#xff09; 1353. 最多可以参加的会议数目 给你一个数组 events&#xff0c;其中 events[i] [startDayi, endDayi] &#xff0c;表示会议 i 开始于 startDayi &#xff0c;结束于 endDayi 。 …

AI+智慧园区 | 事件处置自动化——大模型重构园区治理逻辑

在智慧园区的建设浪潮中&#xff0c;事件管理一直是园区高效运营的关键环节。考拉悠然所推出的大模型 智慧园区解决方案&#xff0c;在事件智能闭环管理方面独树一帜&#xff0c;为园区的日常运营编织了一张严密、高效、智能的管理网络&#xff0c;实现了从事件感知到处置的全…

FFmpeg Windows安装

FFmpeg 用于音频文件转换 Builds - CODEX FFMPEG gyan.dev ffmpeg-release-full.7z 下载完成之后 zip解压 大概就是 ffmpeg/ └── bin/ └── ffmpeg.exe 配置环境变量 ffmpeg -version 有可能idea还是找不到命令 就把命令路径写在程序里 例如

【2025/07/10】GitHub 今日热门项目

GitHub 今日热门项目 &#x1f680; 每日精选优质开源项目 | 发现优质开源项目&#xff0c;跟上技术发展趋势 &#x1f4cb; 报告概览 &#x1f4ca; 统计项&#x1f4c8; 数值&#x1f4dd; 说明&#x1f4c5; 报告日期2025-07-10 (周四)GitHub Trending 每日快照&#x1f55…