AudioRecord obtainBuffer Timed out with AudioRecorder.startRecording()

[亡魂溺海] 提交于 2019-12-13 06:22:46

问题


I have a problem with my program which records the microphone. Sometimes when I run it I have the following warnings and no sound is actually recorded:

12-14 11:17:50.660: W/AudioRecord(1857): obtainBuffer timed out (is the CPU pegged?) user=00000000, server=00000000

From what I have found, other have this problem with AudioTrack as explained here and here. However, for me it is AudioRecord which is not working properly. I understand that the buffer cannot be created for whatever reason. The warning start to appear when I start the recording process: recorder.startRecording();

This problem happens sometimes when I use the built-in microphone as input, but often when the Bluetooth headset is used as input. Here is my code to use the Bluetooth microphone as input:

audioManage = (AudioManager)this.getSystemService(Context.AUDIO_SERVICE);

if (!audioManage.isBluetoothScoOn()) {
    audioManage.setBluetoothScoOn(true);
    audioManage.startBluetoothSco();
    audioStreaming = new AudioStreaming();
} else {
    audioManage.startBluetoothSco();
    audioStreaming = new AudioStreaming();
}

How can I force the buffer creation?

INFO: I'm using Android 3.0 and I've tested the program on a Xoom tablet.

EDIT:

I just realised that I've got this error too:

12-14 12:13:12.500: E/AudioPostProcessor(2541): Error reading from audio in: Connection timed out

Only when the program is not working with the Bluetooth. And I haven't found anything on the subject...


回答1:


Try to use buffer larger than minSize and low down the sample rate. The message usually means some thing wrong in kernel level, like buggy ALSA audio driver integration, but I don't know if Xoom will run into the case. So, Good Luck!




回答2:


Hum, the solution was quite simple... I just didn't checked if new updates where available... Problem has been fixed on it own then.



来源:https://stackoverflow.com/questions/8503874/audiorecord-obtainbuffer-timed-out-with-audiorecorder-startrecording

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!