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. 文献阅读01:由I类HLA转录缺失导致的联合免疫治疗的获得性癌症耐药性

    背景 Merkel cell carcinoma:梅克尔细胞癌又名皮肤小梁状癌.原发性皮肤神经内分泌癌.皮肤原发性小细胞癌及皮肤APUD瘤. HLA:MHC基因产物在不同细胞表面表达,通常称之为MHC ...

  2. python学习day 02

    昨日内容回顾 typora软件 1.作为一款逐年火爆的文本编辑器,深受IT行业的喜爱. 2.下载与安装: windows用群里发的软件 macOS下载地址:https://mac.qdrayst.co ...

  3. 2.16 win32信息 事件 机制-创建第一个win32程序

    事件和信息 事件,例如鼠标的单机 会保存很多数据 这个便是信息 Windows为了能够准确的描述这些信息,提供了一个结构体:MSG,该结构体里面记录的事件的详细信息. typedef struct t ...

  4. SQL Server数据库日常检查

    1.1代码检查从昨天到现在,SQL代理Job有没有运行失败的,会把运行失败的Job名字,步骤,运行时间,错误等级,错误原因罗列出来,方便查看. ----1.1  Check Job Fail List ...

  5. 分布式共识算法随笔 —— 从 Quorum 到 Paxos

    分布式共识算法随笔 -- 从 Quorum 到 Paxos 本文主要参考各类英文文献,部分专业术语翻译较为生硬,望谅解. 概览: 为什么需要共识算法? 昨夜西风凋碧树,独上高楼,望尽天涯路 复制(Re ...

  6. Python:Excel自动化实践入门篇 甲【留言点赞领图书门票】

    *以下内容为本人的学习笔记,如需要转载,请声明原文链接微信公众号「englyf」https://mp.weixin.qq.com/s?__biz=MzUxMTgxMzExNQ==&mid=22 ...

  7. 欢迎来到 SIXIANG 的 blog~

    很欢迎呢~ SX,海豹叉 Luogu OIer,whker,养老人

  8. Vulhub 漏洞学习之:ActiveMQ

    Vulhub 漏洞学习之:ActiveMQ 目录 Vulhub 漏洞学习之:ActiveMQ 1 ActiveMQ反序列化漏洞(CVE-2015-5254): 1.1 漏洞利用过程 2 ActiveM ...

  9. STM32L4 Keil ST-Link 连接失败

    ST-LINK 连接失败的因素,以我个人的经历而言有两种:一个是驱动问题,一个是插线问题.连接正常的情况如下图所示,SWDIO 能显示你的设备信息: 注意使用 SW 端口,JTAG 端口导致无法识别设 ...

  10. 基于C++的OpenGL 04 之变换

    1. 概述 本文基于C++语言,描述OpenGL的变换 前置知识可参考: 基于C++的OpenGL 03 之纹理 - 当时明月在曾照彩云归 - 博客园 (cnblogs.com) 笔者这里不过多描述每 ...