android audiorecord初始化失败相关资料收集
We're also struggling with audio recording on some Samsung Android Devices. Unfortunately it seems to be very broken, as even different revisions of the same phone model are behaving differently with the same codebase.
Here are my current findings, hoping you find something useful:
1. Broken Initialization:
Unfortunately, the strategy you are using to query for valid recording configurations will fail at least on Samsung Galaxy Young and Ace models running Android 2.3 The problem is that some invalid AudioRecord configurations instead of simply failing, will completely brick the audio capture subsystem if tried. You'll need to reset the phone to recover from this state.
2. Inconsistent Sampling-Rate support along revisions of same phone model
On an older Galaxy Ace Phone, recording @ 11025Hz, 16-bit mono will succeed. On newer Ace revisions, this AudioRecord configuration will be accepted as valid, but the resulting recording will be distorted, with a "chipmunk" effect. A very popular guitar tuner app that has hardcoded this sampling rate is failing to give proper tuning readings on these phones precisely because of this problem!
3. Extremely low volume audio capture on some configurations.
In Galaxy Young and Galaxy Ace, recording from the mic or default audio source @ 44,100Hz (the supposedly canonical rate where everything should work fine) produces an undistorted, but extremely low-volume recording. I haven't found yet a way to fix this other than software amplification (which is the equivalent of magnifying a very low res image, with the consecuent "jageddnes" of the result).
4. Failure to support the canonical 44,100Hz sampling rate on every audio capture source.
In Galaxy Young and Galaxy Ace, recording from the Camcorder source fails @ 44,100Hz. (again, the configuration will be accepted as valid) producing complete garbage. However, recording @ 8,000Hz, 16,000Hz and 48,000Hz works fine and produces a recording with very acceptable volume levels. What is frustrating is that according to the Android documentation, 44,100Hz is a sampling rate all devices SHOULD support.
5. OpenSL does not fix any of the problems reported.
Working with the NDK and OpenSL produces the same described results. It seems that the AudioRecorder class is simply wrapping calls to OpenSL, and the problem is either hardware based, or buried at a lower-level tier in the kernel code.
This situation is very unfortunately indeed, as these models are becoming very popular - at least in Mexico.
Good luck - and please report if you had better luck working with these phones. =)
一种通用的初始化audiorecord的方式:
private static int[] mSampleRates = new int[] { 8000, 11025, 22050, 44100 };
public AudioRecord findAudioRecord() {
for (int rate: mSampleRates) { for (short audioFormat: new short[] { AudioFormat.ENCODING_PCM_8BIT, AudioFormat.ENCODING_PCM_16BIT }) { for (short channelConfig: new short[] { AudioFormat.CHANNEL_IN_MONO, AudioFormat.CHANNEL_IN_STEREO }) { try { Log.i("vipul", "Attempting rate " + rate + "Hz, bits: " + audioFormat + ", channel: " + channelConfig); int bufferSize = AudioRecord.getMinBufferSize(rate, channelConfig, audioFormat); if (bufferSize != AudioRecord.ERROR_BAD_VALUE) { // check if we can instantiate and have a success AudioRecord recorder = new AudioRecord( AudioSource.DEFAULT, rate, channelConfig, audioFormat, bufferSize); if (recorder.getState() == AudioRecord.STATE_INITIALIZED) return recorder; } } catch (Exception e) { e.printStackTrace(); } } } } return null;}
android audiorecord初始化失败相关资料收集的更多相关文章
- AssetBundle机制相关资料收集
原地址:http://www.cnblogs.com/realtimepixels/p/3652075.html AssetBundle机制相关资料收集 最近网友通过网站搜索Unity3D在手机及其他 ...
- FastAdmin 导入 Excel 相关资料收集 (2018-08-14)
FastAdmin 导入 Excel 相关资料收集 新版本一键CRUD后自带导入功能,但是默认被禁用,如何启动 https://forum.fastadmin.net/thread/540 Excel ...
- FastAdmin 导出 Excel 相关资料收集 (2018-08-14)
FastAdmin 导出 Excel 相关资料收集 导出 Excel 文件时身份证号变成科学计数法怎么办? https://forum.fastadmin.net/thread/1346 姊妹篇 Fa ...
- Android Notification 消息通知 相关资料.md
目录 Android Notification 消息通知 相关资料 Android 5.0 Lollipop (API 21)无法正常显示通知图标,只能看到一个白色方块或灰色方块的问题 解决方案 参考 ...
- iOS10以及xCode8相关资料收集
兼容iOS 10 资料整理笔记 源文:http://www.jianshu.com/p/0cc7aad638d9 1.Notification(通知) 自从Notification被引入之后,苹果就不 ...
- MPEG 编解码相关资料收集
以下是我搜集的关于MPEG1/2的编解码相关的资料: (注:mpge帧内编码是基于jpeg编码的,所以请务必先理解jpeg的编解码原理.) 1:Introduction to MPEG 2 Video ...
- Android ADT初始化失败
在android的官网上买下载android的adt完了,进行解压之后,开始点击 eclipse.exe,果然给了我一个惊喜,那就是 [ Failed to create the Java Virtu ...
- kafka负载均衡相关资料收集(三)
apache kafka系列之Producer处理逻辑 下文是转载的,原文链接地址:点这儿 [转] Kafka ProducerKafka Producer处理逻辑kafka生产者处理逻辑apache ...
- kafka负载均衡相关资料收集(二)
[转]关于kafka producer 分区策略的思考 from:http://blog.csdn.net/ouyang111222/article/details/51086037 今天跑了一个简单 ...
- kafka负载均衡相关资料收集(一)
key为null时Kafka会将消息发送给哪个分区? 当你编写kafka Producer时, 会生成KeyedMessage对象. 1 KeyedMessage<K, V> keyedM ...
随机推荐
- OpenStack命令行参考
OpenStack命令行参考 hello,大家好,这里是费冰.在使用OpenStack的过程中,固然我们可以通过 web 页面完成绝大多数的操作,但作为管理人员,不能不知晓 OpenStack 命令行 ...
- 11月17日内容总结——黏包现象、struct模块和解决黏包问题的流程、UDP协议、并发编程理论、多道程序设计技术及进程理论
目录 一.黏包现象 什么是黏包 黏包现象产生的原因 二.struct模块及解决黏包问题的流程 struct模块 解决黏包问题初级版本 解决过程中遇到的问题 解决黏包问题终极解决方案 三.粘包代码实战 ...
- 无法加载 DLL“*******.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。
无法加载 DLL"Lib\WeWorkFinanceSdk.dll": 找不到指定的模块. (异常来自 HRESULT:0x8007007E). 网上查找了一大堆,没找到是什么问题 ...
- java_web案例文件下载案例
目的:完成javaweb的文件下载 <!--如果想要一个a标签点击后不论文件类型,都需要弹出下载,保存框:--><!--我们就需要创建一个servlet,让这个a标签指向servle ...
- 华为云发布分布式编译构建系统CodeArts Build
摘要:2月14日,华为云发布分布式编译构建系统CodeArts Build,旨在支撑企业实现高效的软件开发,缩短产品上市周期,帮助企业的软件产品快速形成关键竞争力. 本文分享自华为云社区<唯快不 ...
- 题解 [ZJOI2007]棋盘制作
把悬线法这个坑填了,还是很简单的 qwq. 悬线法一般解决有一定约束条件的最大矩形问题.悬线的定义是从一个点一直往上走直到边界或者不符合条件结束. 炒个例子,在这题里面比如说有这样一个矩形 0 1 0 ...
- Binary &Op是什么
前言 在并行开发时我们经常会用到Pstream::gather()函数或是全局函数reduce()或者其他,需要输入参数Binary &Op,本篇主要讨论Binary &Op是什么 t ...
- CCRD_TOC_2008年第2期
中信国健临床通讯 2008年第2期 目 录 类风湿关节炎 1. 纵向分析TEMPO数据:放射学损伤程度和进展速率决定了关节物理功能 van der Heijde D, et al. Ann Rhe ...
- PostgreSQL 并行计算算法,参数,强制并行度设置
一.优化器并行计算的并行度计算方法 1.总worker进程数 postgres=# show ; max_worker_processes ---------------------- 128 (1 ...
- 常用的"小脚本"-json数据处理
小背景: 我们公司项目中的小脚本是一些工具类,比如常用的是MapUtil工具类的一些方法 写公司的MapUtil工具类的方法要注意,方法名的命名,因为方法名,在公司的项目的某个业务流程有对方法名的进行 ...