简体   繁体   English

Android AudioRecord-本机初始化失败

[英]Android AudioRecord - native init failed

I'm trying to use Pure Data in my android app to do some beat detection. 我正在尝试在我的android应用中使用Pure Data做一些节拍检测。 I had the basic functionality working before, but after refactoring my code and expanding the app, libpd is failing to properly create the AudioRecord instance required. 我之前具有基本功能,但是在重构代码并扩展应用程序之后,libpd无法正确创建所需的AudioRecord实例。 Here are the errors I am getting: 这是我遇到的错误:

[ android.media.AudioTrack ] getMinBufferSize(): Invalid channel configuration.
[ android.media.AudioTrack ] getMinBufferSize(): Invalid channel configuration.
set(): sampleRate 44100, channels 12, frameCount 8832
Could not get audio input for record source 1
Error creating AudioRecord instance: initialization check failed.
[ android.media.AudioRecord ] Error code -20 when initializing native AudioRecord object.
java.io.IOException: unable to initialize AudioRecord instance for sr: 44100, ch: 2, bufSize: 4416
set(): sampleRate 44100, channels 16, frameCount 8832
Could not get audio input for record source 1
Error creating AudioRecord instance: initialization check failed.
[ android.media.AudioRecord ] Error code -20 when initializing native AudioRecord object.
java.io.IOException: unable to initialize AudioRecord instance for sr: 44100, ch: 1, bufSize: 4416

Error code -20 means that native initialization failed, so I am at a loss on what to do now. 错误代码-20表示本机初始化失败,所以我对现在该做什么不知所措。 I do have the RECORD_AUDIO permission in my manifest. 我的清单中确实有RECORD_AUDIO权限。 Do you have any suggestions? 你有什么建议吗?

I've seen that error before where I had been developing a lot and probably forgot to release an AudioRecord. 在进行大量开发之前,我已经看到了该错误,并且可能忘记了发布AudioRecord。 So make sure you try restarting the phone and not having any other recording apps going. 因此,请确保您尝试重新启动手机,并且没有其他录音应用程序运行。

Just like you can sometimes crash an app and still have music playing after the app is dead, I guess this is one of those situations where the hardware can be left in a bad state even after the process is killed. 就像您有时可能会崩溃某个应用程序并在该应用程序停止运行后仍然播放音乐一样,我想这是即使在进程被终止后,硬件也可能处于不良状态的一种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM