Android: Microphone AudioSource causing unsupported parameter, VerifyAndSetParameter failed errors
This question has also been asked at Problems with MediaRecorder class setting audio source - setAudioSource() - unsupported parameter, however this author accepted the answer stating that this only occurs on the emulator, while (for me) this is not the case.
The problem occurs on my device, a Galaxy S i9000. The device has a microphone and recording with the microphone works regardless of this error.
The following code reproduces this error (called inside a service):
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);
Setting the sample rate to a lower value like 8000 does not solve the problem. Setting the channelMode to stereo does not solve the problem.
When executing this code inside my service while the microphone is available for usage, the following errors will be returned:
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.32开发者_StackOverflow8: 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]
Does anyone have a solution to this problem?
First, put this in your manifest file:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Then, you should uninstall your app, and install it again to bring the permission into effect.
I had the same issue as you did. In my case it turned out that the phone SD card is mounted to my PC as USB storage when I connect my Android phone to my machine through USB. (which makes the App could not get access to the file on the phone SD card)
It worked fine after I turn off the USB storage on my Xperia 10.
精彩评论