Android:Microphone AudioSource导致不支持的参数,VerifyAndSetParameter失败错误

时间:2011-01-28 13:51:47

标签: java android audio audio-recording microphone

此问题也在Problems with MediaRecorder class setting audio source - setAudioSource() - unsupported parameter被问到,但是作者接受了答案,说明这只发生在模拟器上,而(对我来说)情况并非如此。

问题出现在我的设备上,即Galaxy S i9000。该设备配有麦克风,无论此错误如何,麦克风都能正常录音。

以下代码重现此错误(在服务中调用):

int sampleRate = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_SYSTEM);
int channelMode = AudioFormat.CHANNEL_IN_MONO;
int encodingMode = AudioFormat.ENCODING_PCM_16BIT; //only 16bit encoding is supported
int bufferSize = AudioRecord.getMinBufferSize(sampleRate, channelMode, encodingMode);
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, channelMode, encodingMode, bufferSize);

将采样率设置为较低的值(如8000)并不能解决问题。将channelMode设置为立体声并不能解决问题。

在麦克风可供使用时,在我的服务中执行此代码时,将返回以下错误:

01-28 14:50:14.860: ERROR/audio_input(2358): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
01-28 14:50:14.860: ERROR/audio_input(2358): VerifyAndSetParameter failed
01-28 14:50:15.246: ERROR/PVOMXEncNode(2358): PVMFOMXEncNode-Audio_AMRNB::DoPrepare(): Got Component OMX.SEC.amrenc handle 
01-28 14:50:15.258: ERROR/audio_input(2358): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
01-28 14:50:15.258: ERROR/audio_input(2358): VerifyAndSetParameter failed
01-28 14:50:15.328: ERROR/audio_input(2358): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
01-28 14:50:15.328: ERROR/audio_input(2358): VerifyAndSetParameter failed
01-28 14:50:15.356: ERROR/PVOMXEncNode(2358): PVMFOMXEncNode-Audio_AMRNB::DoPrepare(): Got Component OMX.SEC.amrenc handle 
01-28 14:50:15.359: ERROR/audio_input(2358): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
01-28 14:50:15.359: ERROR/audio_input(2358): VerifyAndSetParameter failed
01-28 14:50:15.367: ERROR/AudioHardwareALSA(2358): AudioStreamInALSA - input   - format = 1, channels = 16, rate = 44100
01-28 14:50:15.367: ERROR/AudioHardwareALSA(2358): AudioStreamInALSA - default - format = 1, channels = 16, rate = 44100
01-28 14:50:15.457: ERROR/AudioFlinger(2358): readInputParameters mInputBytes 8320, mFrameSize 2 mSampleRate 44100 mChannelCount(1)
01-28 14:50:15.457: ERROR/(2358): AFCCreateReSampler: avAFCInfo->bUsed[0] inSampleRate[44100] outSampleRate[44100] nChannel[1] outbitDepth[16]

有没有人能解决这个问题?

2 个答案:

答案 0 :(得分:2)

首先,将它放在清单文件中:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

然后,您应该卸载您的应用,然后重新安装它以使权限生效。

答案 1 :(得分:1)

我和你一样有同样的问题。在我的情况下,当我通过USB将我的Android手机连接到我的机器时,结果证明手机SD卡作为USB存储器安装在我的PC上。 (这使得App无法访问手机SD卡上的文件)

在关闭Xperia 10上的USB存储设备后,它工作正常。