Android AudioRecord - 本机初始化失败

发布于 2024-12-17 19:54:56 字数 1091 浏览 0 评论 0原文

我正在尝试在我的 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 技术交流群。

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

发布评论

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

评论(1

咋地 2024-12-24 19:54:56

我之前在进行大量开发时曾见过该错误,并且可能忘记发布 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.

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