Android音频相关

 AudioTrack: set: Create AudioTrackThread
加此log来判断是否AudioTrack完整的过程,保证用完后释放。
Log.d(TAG,"2017 Create Track end:"+mAudioTrack.getAudioSessionId());
Log.d(TAG,"2017 Create Track end:"+mAudioTrack.getStreamType());


Log.d(TAG,"2017 Delete Track end:"+mAudioTrack.getAudioSessionId());
Log.d(TAG,"2017 Delete Track end:"+mAudioTrack.getStreamType());


判断AudioTrack最多支持创建多少个?
/frameworks/av/services/audioflinger/AudioMixer.h
有定义,注意单纯改这个宏不能增加最多支持的Track 数,注释也有说明
AudioMixer 中用一个unsigned int32 变量的每一个Bit表示一个track 


86 // This mixer has a hard-coded upper limit of 32 active track inputs.
87 // Adding support for > 32 tracks would require more than simply changing this value.
88 static const uint32_t MAX_NUM_TRACKS = 32;
89 // maximum number of channels supported by the mixer 

 

1. 设备定义: ( /system/core/include/system/audio.h)

 


[cpp] view plain copy
// output devices  
DEVICE_OUT_EARPIECE = 0x1,  
DEVICE_OUT_SPEAKER = 0x2,  
DEVICE_OUT_WIRED_HEADSET = 0x4,  
DEVICE_OUT_WIRED_HEADPHONE = 0x8,  
DEVICE_OUT_BLUETOOTH_SCO = 0x10,  
DEVICE_OUT_BLUETOOTH_SCO_HEADSET = 0x20,  
DEVICE_OUT_BLUETOOTH_SCO_CARKIT = 0x40,  
DEVICE_OUT_BLUETOOTH_A2DP = 0x80,  
DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,  
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,  
DEVICE_OUT_AUX_DIGITAL = 0x400,  
DEVICE_OUT_ANLG_DOCK_HEADSET = 0x800,  
DEVICE_OUT_DGTL_DOCK_HEADSET = 0x1000,  
DEVICE_OUT_FM_HEADPHONE = 0x800,  
DEVICE_OUT_FM_SPEAKER = 0x1000,  
DEVICE_OUT_SPEAKER_SSPA2 = 0x2000,  
DEVICE_OUT_HDMI = 0x4000,  
DEVICE_OUT_FM_TRANSMITTER = 0x8000,  
DEVICE_OUT_DEFAULT = 0x8000,  
  
  
// input devices  
DEVICE_IN_COMMUNICATION = 0x10000,  
DEVICE_IN_AMBIENT = 0x20000,  
DEVICE_IN_BUILTIN_MIC = 0x40000,  
DEVICE_IN_BLUETOOTH_SCO_HEADSET = 0x80000,  
DEVICE_IN_WIRED_HEADSET = 0x100000,  
DEVICE_IN_AUX_DIGITAL = 0x200000,  
DEVICE_IN_VOICE_CALL = 0x400000,  
DEVICE_IN_BACK_MIC = 0x800000,  
DEVICE_IN_VT_MIC  = 0x1000000,  
DEVICE_IN_FMRADIO  = 0x2000000,  
DEVICE_IN_DEFAULT = 0x80000000,  


2. 输出设备:
1) 设备解释
[cpp] view plain copy
DEVICE_OUT_EARPIECE                 : 听筒  
  
DEVICE_OUT_SPEAKER                  : 扬声器  
  
DEVICE_OUT_WIRED_HEADSET            : 带话筒的耳机  
DEVICE_OUT_WIRED_HEADPHONE          : 不带话筒的耳机  
  
DEVICE_OUT_BLUETOOTH_SCO            : 蓝牙.面向连接(SCO)方式:主要用于话音传输  
DEVICE_OUT_BLUETOOTH_SCO_HEADSET    : 蓝牙耳机,带话筒  
DEVICE_OUT_BLUETOOTH_SCO_CARKIT     : 蓝牙车载设备  
DEVICE_OUT_BLUETOOTH_A2DP           : 蓝牙立体声  
DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES: 蓝牙立体声音耳机  
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER   : 带话筒的  
  
DEVICE_OUT_AUX_DIGITAL              : The audio output device code for S/PDIF or HDMI. S/PDIF的全称是Sony/Philips Digital Interface Format  
DEVICE_OUT_ANLG_DOCK_HEADSET        : 通过基座连接的模拟有线耳机  
DEVICE_OUT_DGTL_DOCK_HEADSET        : 通过基座连接的数字有线耳机  
DEVICE_OUT_FM_HEADPHONE             :   
DEVICE_OUT_FM_SPEAKER  
DEVICE_OUT_SPEAKER_SSPA2  
DEVICE_OUT_HDMI  
DEVICE_OUT_FM_TRANSMITTER  
2) 蓝牙解析


    蓝牙基带技术支持两种连接方式:
        面向连接(SCO)方式:主要用于话音传输;
        无连接(ACL)方式:主要用于分组数据传输。
    A2DP是Advanced Audio Distribution Profile, 是立体声的.
    AV只管输出,立体的,没有输入; SCO管通讯,有输出也有接收,但是单声道的


3) 参考资料:
http://zhidao.baidu.com/question/186011381.html
http://zhidao.baidu.com/question/392379495.html
http://auction1.paipai.com/FD51190F00000000007D3A1606AFD424
http://baike.baidu.com/view/551149.htm


3. 输入设备


[cpp] view plain copy
DEVICE_IN_COMMUNICATION         : 手机上的话筒  
DEVICE_IN_AMBIENT               :  
DEVICE_IN_BUILTIN_MIC           : 蓝牙麦克  
DEVICE_IN_BLUETOOTH_SCO_HEADSET : 蓝牙耳机上的话筒  
DEVICE_IN_WIRED_HEADSET         : 有线耳机上的话筒  
DEVICE_IN_AUX_DIGITAL           :  
DEVICE_IN_VOICE_CALL            :  
DEVICE_IN_BACK_MIC              :  
DEVICE_IN_VT_MIC                :   
DEVICE_IN_FMRADIO               : FM中的输入.  


Android has an interesting command called dumpsys  to dump some system information. Even described on adb manual  I think that some points should be reinforced. In order to get the complete status just run (will produce a large output):
adb shell dumpsys
Also you can apply filters to running services:
1 SurfaceFlinger
2 accessibility
3 account
4 activity
5 alarm
6 appwidget
7 audio
8 backup
9 battery
10 batteryinfo
11 bluetooth
12 bluetooth_a2dp
13 clipboard
14 connectivity
15 content
16 cpuinfo
17 device_policy
18 devicestoragemonitor
19 diskstats
20 dropbox
21 entropy
22 ethernet
23 hardware
24 input_method
25 iphonesubinfo
26 isms
27 keybar
28 location
29 media.audio_flinger
30 media.audio_policy
31 media.camera
32 media.player
33 meminfo
34 mount
35 netstat
36 network_management
37 notification
38 package
39 permission
40 phone
41 power
42 search
43 sensorservice
44 simphonebook
45 statusbar
46 telephony.registry
47 throttle
48 uimode
49 usagestats
50 vibrator
51 wallpaper
52 wifi
53 window
Some examples:
adb shell dumpsys wifi
adb shell dumpsys cpuinfo
I suggest you try other items on the list above and be creative using all the power of Unix pipes. Example, to get all memory allocated by each process you can do something like:
adb shell dumpsys meminfo | grep "allocated:" | awk '{total = total + $5}END{print total}'








数字音乐相关的术语:


位宽: bit depth ,每次采样的信息量




信道: 播放或者录制时流的数量


downmix:降道Decrease the number of channels, such as from stereo(立体音) to mono(单声道) or from 5.1 to stereo.


duck :暂时降低音量(比如说听音乐的时候来了短信,会暂时降低音乐的音量)


帧: 所有采样的集合(同一时间多个信道)


音频转换(音频数据流向)




ADC:模拟信号转数字信号的转换器(Analog-to-digital)


DAC:数字信号转模拟信号的转换器


AP:应用处理器(用于手机的)


Codec:编码和解码音频信号Coder-decoder


DSP: digital signal processr(数字信号处理器)(输入的时候,先于应用处理器;输出的时候,后于应用处理器)


PDM:??


PWM: ??


内部器件交互






<--------下面基本全部不懂-------->




GPIO
I²C, for control channel
I²S, for audio data, simpler than SLIMbus
McASP
SLIMbus
SPI
AC'97
Intel HDA
SoundWire


外部器件交互(就是一些外部接口)




蓝牙


display port


dongle


hdmi


mhl (mobile high-definition link)


slim port (adapter from micro-usb to hdmi)


thrnderbolt




采样率相关






down sample 降低采样率 (采样率输出比源的频率要低)




upsample 补强(采样率输出比源的频率要高)




sampler 采样器 (就是一个频率转换器)




simk (采样器的输出)




source (采样器的音源)




20 Hz to 20 kHz 人的听力范围,所以采样率的频率最大保持在40kHz就已经满足人的最大听力范围了




(Nyquist frequency理论认为采样率的1/2就是人的最大听力范围)




Android相关


ALSA & tinyalsa : (kernel audio framework and drivers)


Audio Device : (依赖HAL层实现的音频流处理的终点)


AudioEffect: (前期和后期)音频(输入输出)效果处理,参见 android.media.audiofx.AudioEffect


AudioFlinger: 音频处理的服务端(跑在media server这个进程里面,media server里面的其他线程也可以调用audio filinger)


AudioFocus: 多个应用间音频焦点的管理


AudioMixer:混音器


AudioPolicy:设备控制(流控制,设备路由控制)


AudioRecord:从input获取PCM音频数据 (android.media.AudioRecord)


AudioResampler:Audio中的其中一个部分,负责audio采样率转换的


AudioSource: (就是一系列常量)一般是指 MediaRecorder.AudioSource,定义了录制音频时的一些列参数(包括音频信号的参数,来源,录制时的配置)


AudioTrack: 发送PCM数据给外放之类的设备(参考android.media.AudioTrack)


Audio_utils: 依赖android平台的一些工具类(pcm格式转换,wav文件caozuo ,无阻塞栈策略)


HAL: audio flinger和kernel device driver 的中间层(放的是C接口)


FastCapture
Thread within AudioFlinger that sends audio data to lower latency fast tracks and drives the input device when configured for reduced latency.
线程内AudioFlinger发送音频数据更低的延迟快速跟踪和驱动输入设备配置为减少延迟。


FastMixer
Thread within AudioFlinger that receives and mixes audio data from lower latency fast tracks and drives the primary output device when configured for reduced latency.
线程在AudioFlinger接收从更低的延迟和混合音频数据快速跟踪和驱动器的主要输出设备,配置降低延迟。


fast track
AudioTrack or AudioRecord client with lower latency but fewer features on some devices and routes.
AudioTrack或AudioRecord客户延迟较低但更少的特征在一些设备和路线。


MediaPlayer
Higher-level client API than AudioTrack. Plays encoded content or content that includes multimedia audio and video tracks.
比AudioTrack高级客户端API。扮演编码内容或内容,包括多媒体音频和视频跟踪。


media.log
AudioFlinger debugging feature available in custom builds only. Used for logging audio events to a circular buffer where they can then be retroactively dumped when needed.
AudioFlinger调试功能可以在自定义构建。用于记录音频事件循环缓冲区,然后他们可以在需要的时候被追溯倾倒。


mediaserver
Android system process that contains media-related services, including AudioFlinger.


NBAIO
Non-blocking audio input/output. Abstraction for AudioFlinger ports. The term can be misleading as some implementations of the NBAIO API support blocking. The key implementations of NBAIO are for different types of pipes.
非阻塞音频输入/输出。抽象AudioFlinger港口。这个词可以被误导为一些NBAIO API的实现支持阻塞。的关键实现NBAIO为不同类型的管道。


normal mixer
Thread within AudioFlinger that services most full-featured AudioTrack clients. Directly drives an output device or feeds its sub-mix into FastMixer via a pipe.
线程在AudioFlinger服务功能齐全的AudioTrack大多数客户。直接驱动输出设备或提要sub-mix到FastMixer通过管道。


OpenSL ES
Audio API standard by The Khronos Group. Android versions since API level 9 support a native audio API that is based on a subset of OpenSL ES 1.0.1.


silent mode(通知和响铃被屏蔽)
User-settable feature to mute the phone ringer and notifications without affecting media playback (music, videos, games) or alarms.
User-settable特性沉默的电话铃声和通知而不影响媒体播放(音乐、视频、游戏)或警报。


SoundPool (上层api)
Higher-level client API than AudioTrack. Plays sampled audio clips. Useful for triggering UI feedback, game sounds, etc. The API is defined at android.media.SoundPool.
比AudioTrack高级客户端API。采样音频剪辑。用于触发UI反馈,游戏声音,等在android.media.SoundPool定义的API。


Stagefright
See Media.


StateQueue
Module within AudioFlinger responsible for synchronizing state among threads. Whereas NBAIO is used to pass data, StateQueue is used to pass control information.
模块内AudioFlinger负责线程间的同步状态。而NBAIO用来传递数据,StateQueue用来传递控制信息


strategy
Group of stream types with similar behavior. Used by the audio policy service.


stream type
Enumeration that expresses a use case for audio output. The audio policy implementation uses the stream type, along with other parameters, to determine volume and routing decisions. For a list of stream types, see android.media.AudioManager.


tee sink
See Audio Debugging.


tinyalsa
Small user-mode API above ALSA kernel with BSD license. Recommended for HAL implementations.


ToneGenerator
Higher-level client API than AudioTrack. Plays dual-tone multi-frequency (DTMF) signals. For details, refer to Dual-tone multi-frequency signaling and the API definition at android.media.ToneGenerator.


track
Audio stream. Controlled by the AudioTrack or AudioRecord API.


volume attenuation curve (??)
Device-specific mapping from a generic volume index to a specific attenuation factor for a given output.


volume index

 

 

Unitless integer that expresses the desired(期望的) relative volume of a stream. The volume-related APIs of android.media.AudioManager operate in volume indices rather than absolute attenuation factors.

 

 

 

 

downmixer是不是被关掉了?MTK宏打开做下验证,如果没有问题,可以downmixer patch。
speaker是接的耳机通道的左声道
audioflinger的信息dump出来
adb shell dumpsys media.audio_flinger >F:\\Log\dump_flinger.txt
coder 数模转换的通道

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值