Android AudioRecord - 本机初始化失败
我正在尝试在我的 Android 应用程序中使用 Pure Data 来进行一些节拍检测。我之前可以使用基本功能,但在重构代码并扩展应用程序后,libpd 无法正确创建所需的 AudioRecord 实例。以下是我收到的错误:
[ 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
错误代码 -20 意味着本机初始化失败,所以我现在不知道该怎么办。我的清单中确实有 RECORD_AUDIO 权限。您有什么建议吗?
I'm trying to use Pure Data in my android app to do some beat detection. 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. 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. I do have the RECORD_AUDIO permission in my manifest. Do you have any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我之前在进行大量开发时曾见过该错误,并且可能忘记发布 AudioRecord。因此,请确保尝试重新启动手机并且没有任何其他录音应用程序运行。
就像有时应用程序崩溃但在应用程序死机后仍然可以播放音乐一样,我想这是即使在进程被终止后硬件也可能处于不良状态的情况之一。
I've seen that error before where I had been developing a lot and probably forgot to release an 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.