Android:麦克风 AudioSource 导致参数不受支持、VerifyAndSetParameter 失败错误

发布于 2024-10-14 11:46:31 字数 2546 浏览 6 评论 0原文

这个问题也被问到 MediaRecorder 类设置音频源的问题- setAudioSource() - 不支持的参数,但是作者接受了答案,指出这只发生在模拟器上,而(对我来说)情况并非如此。

我的设备 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]

有人能解决此问题吗?

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.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]

Does anyone have a solution to this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

日久见人心 2024-10-21 11:46:31

首先,将其放入您的清单文件中:

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

然后,您应该卸载您的应用程序,然后再次安装它以将许可生效。

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.

高跟鞋的旋律 2024-10-21 11:46:31

我和你有同样的问题。就我而言,当我通过 USB 将 Android 手机连接到我的机器时,手机 SD 卡作为 USB 存储安装到我的电脑上。
(这使得应用程序无法访问手机 SD 卡上的文件)

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文