在Android中从MIC获取音频

时间:2011-10-18 10:15:10

标签: android

我创建了一个应用程序,它将从MIC中获取声音并以dB为单位显示其频率级别。

但是当我运行应用程序时,logcat会出现错误。
10-18 15:38:17.651: ERROR/ALSALib(2376): external/alsa-lib/src/pcm/pcm.c:2201(snd_pcm_open_noupdate) Unknown PCM AndroidRecord_Speaker 10-18 15:38:17.651: ERROR/ALSALib(2376): external/alsa-lib/src/pcm/pcm.c:2201:(snd_pcm_open_noupdate) Unknown PCM NULL_Device 10-18 15:38:17.651: INFO/AudioHardwareALSA(2376): Initialized ALSA CAPTURE device NULL_Device 10-18 15:38:17.651: ERROR/AudioHardwareALSA(2376): open (0,0x40000) = -2 10-18 15:38:17.651: ERROR/AudioHardwareALSA(2376): setInputDevice(0 , 0x40000) = -2 10-18 15:38:17.651: ERROR/AudioRecord(3461): Could not get audio input for record source 1 10-18 15:38:17.651: ERROR/AudioRecord-JNI(3461): Error creating AudioRecord instance: initialization check failed. 10-18 15:38:17.655: ERROR/AudioRecord-Java(3461): [ android.media.AudioRecord ] Error code -20 when initializing native AudioRecord object. 10-18 15:38:17.655: WARN/dalvikvm(3461): threadid=8: thread exiting with uncaught exception (group=0x4001d7d0) 10-18 15:38:17.659: ERROR/AndroidRuntime(3461): FATAL EXCEPTION: Thread-9 10-18 15:38:17.659: ERROR/AndroidRuntime(3461): java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord. 10-18 15:38:17.659: ERROR/AndroidRuntime(3461): at android.media.AudioRecord.startRecording(AudioRecord.java:495) 10-18 15:38:17.659: ERROR/AndroidRuntime(3461): at com.android.spl.Recorder.run(Recorder.java:178) 10-18 15:38:17.659: ERROR/AndroidRuntime(3461): at java.lang.Thread.run(Thread.java:1096)

由于 请有人帮助我......

1 个答案:

答案 0 :(得分:0)

答案就在那里

startRecording()调用未初始化的AudioRecord。