AudioRecord.read keep blocking and throwing " obtainBuffer timed out"

264 views
Skip to first unread message

Jammy

unread,
Apr 1, 2010, 10:31:19 PM4/1/10
to Android Developers
I am writing a VOIP phone application and testing it on MOTO
milestime. Sometime I meet a "obtainBuffer timed out" exception when i
am calling AudioRecord.read , it don't return me any result but just
block the thread. Runing on emulator with 1.5 OS won't get this
exception. My codes:

AudioRecord record = new AudioRecord(
MediaRecorder.AudioSource.MIC, 8000,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT,
// 100000
AudioRecord.getMinBufferSize(8000,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT)
);
record.startRecording();
int num = record.read(lin,offsetInShorts ,sizeInShorts);
.......
......
when it is blocked , run these code can solve the problem.
AudioManager am = (AudioManager)
Receiver.mContext.getSystemService(Context.AUDIO_SERVICE);
am.setMode(mode);
am.setMode(AudioManager.MODE_NORMAL);
..............
am.setMode(AudioManager.MODE_INCALL);

Anybody have any idea on this ?

Jammy

unread,
Apr 1, 2010, 10:33:18 PM4/1/10
to Android Developers
fix some typo. I am testing on MOTO milestone (not milestime)

Jammy

unread,
Apr 1, 2010, 10:38:28 PM4/1/10
to Android Developers
The full exception messages:

04-01 14:16:06.288: ERROR/AudioHardwareMot(1056): AudioMgr
Error:AudioStreamInMot::read: codec device busy

04-01 14:16:06.288: ERROR/AudioFlinger(1056): Error reading audio
input

04-01 14:16:06.351: WARN/AudioRecord(4010): obtainBuffer timed out (is
the CPU pegged?) user=00000640, server=00000640
04-01 14:16:07.291: WARN/AudioRecord(4010): obtainBuffer timed out (is
the CPU pegged?) user=00000640, server=00000640

04-01 14:16:07.296: ERROR/AudioHardwareMot(1056): AudioMgr
Error:AudioStreamInMot::read: codec device busy

Reply all
Reply to author
Forward
0 new messages