Android 4.4 Kitkat 音频实现及简要分析
版权声明:本文为博主原创文章,未经博主同意不得转载。 https://blog.csdn.net/jingxia2008/article/details/26701899
在 Android 4.4 上实现录放音
背景
总的来说改进还是非常大,至少在用户体验上已经大大的超越了之前的版本号。
我们就从 4.4 的音频实现上来分析当中的一些变化和实现机制。
要求
HAL
Android 的配置
调试
这几个移植了一些通用的 alsa 设备打开配置功能,可是详细平台却并不一定都能正常运行,主要是这些库实现都非常easy,没有考虑全面,你的硬件细节可能刚好被他们忽略了。相同以我们的 wm8904 来说,我们不支持 time stamp ,可是 tinyalsa 是默认打开的必须将其关掉。
disable tstamp for wm8904.
Change-Id: Ia22aa6ed39ede6214657487344d0488be93e5544
diff --git a/pcm.c b/pcm.c
index 4501777..94cf6ee 100644
--- a/pcm.c
+++ b/pcm.c
@@ -691,7 +691,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device,
memset(&sparams, 0, sizeof(sparams));
- sparams.tstamp_mode = SNDRV_PCM_TSTAMP_ENABLE;
+ sparams.tstamp_mode = SNDRV_PCM_TSTAMP_NONE;
sparams.period_step = 1;
if (!config->start_threshold) {
详细哪些參数不正确,或者不合适,就须要 Android 驱动project师依据硬件设计和芯片手冊,逐个查证。配置到一个音频系统工作的最佳状态。
那么用户体验才干最好。
Android 音频系统分析
audio HAL
tinyalsa 与 audioroute
static inline int audio_hw_device_open(const struct hw_module_t* module,
struct audio_hw_device** device)
{
return module->methods->open(module, AUDIO_HARDWARE_INTERFACE,
(struct hw_device_t**)device);
}
static inline int audio_hw_device_close(struct audio_hw_device* device)
{
return device->common.close(&device->common);
}
须要实现 in 和 out 的 数据流
/* Open and close a stream */
struct pcm *pcm_open(unsigned int card, unsigned int device,
unsigned int flags, struct pcm_config *config);
int pcm_close(struct pcm *pcm);
int pcm_is_ready(struct pcm *pcm);
/* Obtain the parameters for a PCM */
struct pcm_params *pcm_params_get(unsigned int card, unsigned int device,
unsigned int flags);
void pcm_params_free(struct pcm_params *pcm_params);
unsigned int pcm_params_get_min(struct pcm_params *pcm_params,
enum pcm_param param);
unsigned int pcm_params_get_max(struct pcm_params *pcm_params,
enum pcm_param param);
/* Set and get config */
int pcm_get_config(struct pcm *pcm, struct pcm_config *config);
int pcm_set_config(struct pcm *pcm, struct pcm_config *config);
/* Returns a human readable reason for the last error */
const char *pcm_get_error(struct pcm *pcm);
/* Returns the sample size in bits for a PCM format.
* As with ALSA formats, this is the storage size for the format, whereas the
* format represents the number of significant bits. For example,
* PCM_FORMAT_S24_LE uses 32 bits of storage.
*/
unsigned int pcm_format_to_bits(enum pcm_format format);
/* Returns the buffer size (int frames) that should be used for pcm_write. */
unsigned int pcm_get_buffer_size(struct pcm *pcm);
unsigned int pcm_frames_to_bytes(struct pcm *pcm, unsigned int frames);
unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int bytes);
/* Returns the pcm latency in ms */
unsigned int pcm_get_latency(struct pcm *pcm);
/* Returns available frames in pcm buffer and corresponding time stamp.
* The clock is CLOCK_MONOTONIC if flag PCM_MONOTONIC was specified in pcm_open,
* otherwise the clock is CLOCK_REALTIME.
* For an input stream, frames available are frames ready for the
* application to read.
* For an output stream, frames available are the number of empty frames available
* for the application to write.
*/
int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail,
struct timespec *tstamp);
/* Write data to the fifo.
* Will start playback on the first write or on a write that
* occurs after a fifo underrun.
*/
int pcm_write(struct pcm *pcm, const void *data, unsigned int count);
int pcm_read(struct pcm *pcm, void *data, unsigned int count);
/*
* mmap() support.
*/
int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count);
int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count);
int pcm_mmap_begin(struct pcm *pcm, void **areas, unsigned int *offset,
unsigned int *frames);
int pcm_mmap_commit(struct pcm *pcm, unsigned int offset, unsigned int frames);
/* Start and stop a PCM channel that doesn't transfer data */
int pcm_start(struct pcm *pcm);
int pcm_stop(struct pcm *pcm);
/* Interrupt driven API */
int pcm_wait(struct pcm *pcm, int timeout);
/* Change avail_min after the stream has been opened with no need to stop the stream.
* Only accepted if opened with PCM_MMAP and PCM_NOIRQ flags
*/
int pcm_set_avail_min(struct pcm *pcm, int avail_min);
tinymix 能够查看和配置音频路径:
root@sama5d3:/ # tinymix
Mixer name: 'wm8904 @ SAMA5D3EK'
Number of controls: 41
ctl type num name value
0 INT 1 EQ1 Volume 12
1 INT 1 EQ2 Volume 12
2 INT 1 EQ3 Volume 12
3 INT 1 EQ4 Volume 12
4 INT 1 EQ5 Volume 12
5 INT 2 Digital Capture Volume 96 96
6 ENUM 1 Left Caputure Mode Single-Ended
7 ENUM 1 Right Capture Mode Single-Ended
8 INT 2 Capture Volume 5 5
9 BOOL 2 Capture Switch Off Off
10 BOOL 1 High Pass Filter Switch On
11 ENUM 1 High Pass Filter Mode Hi-fi
12 BOOL 1 ADC 128x OSR Switch On
13 INT 1 Digital Playback Boost Volume 0
14 INT 2 Digital Playback Volume 96 96
15 INT 2 Headphone Volume 45 45
16 BOOL 2 Headphone Switch On On
17 BOOL 2 Headphone ZC Switch On On
18 INT 2 Line Output Volume 57 57
19 BOOL 2 Line Output Switch On On
20 BOOL 2 Line Output ZC Switch On On
21 BOOL 1 EQ Switch Off
22 BOOL 1 DRC Switch Off
23 ENUM 1 DRC Path ADC
24 BOOL 1 DAC OSRx2 Switch Off
25 BOOL 1 DAC Deemphasis Switch Off
26 INT 2 Digital Sidetone Volume 0 0
27 ENUM 1 LINER Mux DAC
28 ENUM 1 LINEL Mux DAC
29 ENUM 1 HPR Mux DAC
30 ENUM 1 HPL Mux DAC
31 ENUM 1 Right Sidetone None
32 ENUM 1 Left Sidetone None
33 ENUM 1 DACR Mux Right
34 ENUM 1 DACL Mux Left
35 ENUM 1 AIFOUTR Mux Right
36 ENUM 1 AIFOUTL Mux Left
37 ENUM 1 Right Capture Inverting Mux IN1R
38 ENUM 1 Right Capture Mux IN2R
39 ENUM 1 Left Capture Inverting Mux IN1L
40 ENUM 1 Left Capture Mux IN2L
audioflinger
Android 4.4 Kitkat 音频实现及简要分析的更多相关文章
- Android 关于 OnScrollListener 事件顺序次数的简要分析
在 Android 的 OnScrollListener 整个事件我主要分析下他的执行顺序: 实现滚动事件的监听接口 new AbsListView.OnScrollListener(){ @Over ...
- Android 4.4 KitKat 新特性
New in Android 4.4 KitKat 本文是一个概览,关于KitKat,也即Android4.4的新东西,先是功能型的,之后是设计上的. 很多特性本文并没有提到,很多提到的特性也只是简短 ...
- [转]Android系统Surface机制的SurfaceFlinger服务简要介绍和学习计划
转自:Android系统Surface机制的SurfaceFlinger服务简要介绍和学习计划 前面我们从Android应用程序与SurfaceFlinger服务的关系出发,从侧面简单学习了Surfa ...
- Android 4.4 KitKat, the browser and the Chrome WebView
Having V8 as the JavaScript engine for the new web view, the JavaScript performance if much better, ...
- 让你的短信应用迎接Android 4.4(KitKat)
原文地址:Getting Your SMS Apps Ready for KitKat 发送和接收短信是手机最基本的功能,很多的开发者也开发了很多成功的应用来增强Android这一方面的体验.你们当中 ...
- Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 10
今天编译一个project,我设置为api 14,可是编译报错: Using 1.7 requires compiling with Android 4.4 (KitKat); currently u ...
- Android 4.4(KitKat)中VSync信号的虚拟化
原文地址:http://blog.csdn.net/jinzhuojun/article/details/17293325 Android 4.1(Jelly Bean)引入了Vsync(Vertic ...
- Android应用程序的Activity启动过程简要介绍和学习计划
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6685853 在Android系统中,Activ ...
- Android 4.4 Kitkat Phone工作流程浅析(六)__InCallActivity显示更新流程
本文来自http://blog.csdn.net/yihongyuelan 转载请务必注明出处 本文代码以MTK平台Android 4.4为分析对象,与Google原生AOSP有些许差异,请读者知悉. ...
随机推荐
- 【web开发学习笔记】Structs2 Result学习笔记(一)简介
Structs2 Result学习笔记(一)简介 问题一 <struts> <constant name="struts.devMode" value=" ...
- ExtjS学习--------Ext.define定义类
Ext类Class的配置项:(注:Extjs的 的中文版帮助文档下载地址:http://download.csdn.net/detail/z1137730824/7748893 ExtJS配置文件和演 ...
- java gc日志详解
从 Full GC 信息可知,新生代可用的内存大小约为 18M,则新生代实际分配得到的内存空间约为 20M(为什么是 20M? 请继续看下面...).老年代分得的内存大小约为 42M,堆的可用内存的大 ...
- ubuntu如何使用minicom
minicom是linux下串口通信的软件,它的使用完全依靠键盘的操作,虽然没有“超级终端”那么易用,但是使用习惯之后读者将会体会到它的高效与便利,下面将讲解minicom的安装和配置. 一.安装mi ...
- apache+svn No installed service name 'Apache2' 【转载】
版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://zys0597.blogbus.com/logs/32763815.html 问题:第一次在winxp下 安装apac ...
- Cut the rope
http://acm.nyist.net/JudgeOnline/problem.php?pid=651 描述We have a rope whose length is L. We will cut ...
- Eigen求矩阵行列式 及 行列式本质
转置.伴随.行列式.逆矩阵 小矩阵(4 * 4及以下)eigen会自动优化,默认采用LU分解,效率不高 #include <iostream> #include <Eigen/Den ...
- 第二章----python基础
概要:python是一种计算机编程语言,有自己的一套语法,编译器或者解释器负责把符合语法的程序代码翻译成CPU能识别的机器码,然后执行.python使用缩进来组织代码块,Python程序中大小写是敏感 ...
- linux 学习笔记1
1.IDE硬盘 /dev/hd[a-d] IDE1 主 /dev/hda 从 /dev/hdb IDE2 主 ...
- Android记住password后自己主动登录
/** * * @author alex * @version 2014-7-31下午5:25:45 * */ public class LoginActivity extends Act ...