简体   繁体   中英

Android AudioRecord - native init failed

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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