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初始化失败相关资料收集的更多相关文章

  1. AssetBundle机制相关资料收集

    原地址:http://www.cnblogs.com/realtimepixels/p/3652075.html AssetBundle机制相关资料收集 最近网友通过网站搜索Unity3D在手机及其他 ...

  2. FastAdmin 导入 Excel 相关资料收集 (2018-08-14)

    FastAdmin 导入 Excel 相关资料收集 新版本一键CRUD后自带导入功能,但是默认被禁用,如何启动 https://forum.fastadmin.net/thread/540 Excel ...

  3. FastAdmin 导出 Excel 相关资料收集 (2018-08-14)

    FastAdmin 导出 Excel 相关资料收集 导出 Excel 文件时身份证号变成科学计数法怎么办? https://forum.fastadmin.net/thread/1346 姊妹篇 Fa ...

  4. Android Notification 消息通知 相关资料.md

    目录 Android Notification 消息通知 相关资料 Android 5.0 Lollipop (API 21)无法正常显示通知图标,只能看到一个白色方块或灰色方块的问题 解决方案 参考 ...

  5. iOS10以及xCode8相关资料收集

    兼容iOS 10 资料整理笔记 源文:http://www.jianshu.com/p/0cc7aad638d9 1.Notification(通知) 自从Notification被引入之后,苹果就不 ...

  6. MPEG 编解码相关资料收集

    以下是我搜集的关于MPEG1/2的编解码相关的资料: (注:mpge帧内编码是基于jpeg编码的,所以请务必先理解jpeg的编解码原理.) 1:Introduction to MPEG 2 Video ...

  7. Android ADT初始化失败

    在android的官网上买下载android的adt完了,进行解压之后,开始点击 eclipse.exe,果然给了我一个惊喜,那就是 [ Failed to create the Java Virtu ...

  8. kafka负载均衡相关资料收集(三)

    apache kafka系列之Producer处理逻辑 下文是转载的,原文链接地址:点这儿 [转] Kafka ProducerKafka Producer处理逻辑kafka生产者处理逻辑apache ...

  9. kafka负载均衡相关资料收集(二)

    [转]关于kafka producer 分区策略的思考 from:http://blog.csdn.net/ouyang111222/article/details/51086037 今天跑了一个简单 ...

  10. kafka负载均衡相关资料收集(一)

    key为null时Kafka会将消息发送给哪个分区? 当你编写kafka Producer时, 会生成KeyedMessage对象. 1 KeyedMessage<K, V> keyedM ...

随机推荐

  1. 在windows系统下用vscode构造shell脚本IDE

    1.基础环境搭建 安装Visual Studio Code(VScode ) 下载地址:https://code.visualstudio.com/Download 下载完双击文件,选择路径安装即可, ...

  2. JSP第十次作业

    1.实现 删除 回复邮件2.实现阅读邮件功能:在main.jsp中点击任意邮件的标题,进入到detail.jsp显示邮件详情,包括发件人,主题,内容,时间.同时需要把邮件状态修改为已读. com.gd ...

  3. 数据同步gossip协议原理与应用场景介绍

    作者:京东物流 冯鸿儒 1 简介 Gossip是一种p2p的分布式协议.它的核心是在去中心化结构下,通过将信息部分传递,达到全集群的状态信息传播,传播的时间收敛在O(Log(N))以内,其中N是节点的 ...

  4. springBoot集成flowable

    前言 Flowable可以十分灵活地加入你的应用/服务/构架.可以将JAR形式发布的Flowable库加入应用或服务,来嵌入引擎. 以JAR形式发布使Flowable可以轻易加入任何Java环境:Ja ...

  5. 定位bug

    软件测试阶段:单元测试,集成测试,系统测试,验收测试 测试人员参与的软件测试阶段一般来说只有集成测试和系统测试阶段.集成测试阶段主要测试的是接口:系统测试阶段主要是功能测试,兼容性测试等,涉及到定位b ...

  6. 视觉十四讲:第六讲_ceres非线性优化

    使用Ceres求解非线性优化问题,一共分为三个部分: 1. 第一部分:构建cost fuction,即代价函数,也就是寻优的目标式.这个部分需要使用仿函数(functor)这一技巧来实现,做法是定义一 ...

  7. uboot启动过程 3

    uboot启动过程1描述到 _start -> reset ->  save_boot_params -> save_boot_params_ret ->  cpu_init_ ...

  8. 队列——queue的用法(及洛谷B3616)

    队列的概念 在说队列之前,先回忆一下栈是什么,我们一般说栈是一个先进后出的数据结构,而队列就是先进先出的数据结构. 队列是定在表的一端进行插入,表的另一端进行删除. 通常,我们称进数据的一端为队尾,出 ...

  9. C# 通过反射获取类字段名和值并加入到字典中(包含递归获取)

    //测试类 public class HKAddvisitor1{    public string code { set; get; }    public string msg { set; ge ...

  10. NSDT可编程3D场景

    推荐:将 NSDT场景编辑器 加入你的3D开发工具链. NSDT编辑器简化了WebGL 3D应用的开发,完全兼容Three.JS生态.本文介绍如何在自己的应用中嵌入使用NSDT编辑器搭建的3D场景,并 ...