您的位置:首页 > 移动开发 > Android开发

android 音频系统工作流程梳理

2014-10-20 15:49 330 查看
ALSA可以分为ALSA driver、ALSA lib、ALSA application三个层次。

 

soc可以分为4个域:

Codec domain ;
Platform/Machine domain;
Path domain -alsamixer, amixer;
sound/soc/codecs目录Stream domain - DACs and ADCs.  aplay, arecord。
 

对codec内部的硬件构件抽象的部件包括:

Mixer      - Mixes several analog signals into a single analog signal.混合多个模拟信号到单个模拟信号Mux        - An analog switch that outputs only one of many inputs.多路模拟信号的选择开关PGA        - A programmable gain amplifier or attenuation widget.ADC        - Analog to Digital ConverterDAC        - Digital to Analog ConverterSwitch     - An analog switchInput      - A codec input pinOutput     - A codec output pinHeadphone  - Headphone (and optional Jack)Mic        - Mic (and optional Jack)Line       - Line Input/Output (and optional Jack)Speaker    - SpeakerPre        - Special PRE widget (exec before all others)Post       - Special POST widget (exec after all others)
 

path的头尾端点就是用SND_SOC_DAPM_INPUT或者SND_SOC_DAPM_OUTPUT定义这个部件。

 

Audio Codec中有许多部件,并且可以是任意的名字,ALSA怎么可能知道该如何操作这些部件来切换到你想要的路径,即时ALSA lib也不会关心这部分内容,这些细微的切换又ALSA application以上来完成,ALSA lib也最多提供各种操作mixer或者Mux的函数,如何切换是你应用的事情。

对部件的操作函数是snd_mixer_selem_set_enum_item(),alsamixer也是通过这个函数达到切换的目的

 

amixer-用户层  

 ->snd_ctl_ioctl-系统调用    

->snd_ctl_elem_write_user-内核钩子函数    
->snd_ctl_elem_wirte
->snd_ctl_find_id-遍历kcontrol链表找到name字段匹配的kctl    
->kctl->put()-调用kctl的成员函数put()    
->snd_soc_put_volsw_2r   
 

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 音频