I have an application on Android that crashes on certain devices and not others.
We are attempting to record sounds through the headphone mike, and on some devices, it just crashes outright, and on others, works fine.
This is the code (and it’s the same code from viewtopic.php?f=7&t=15575)
[code:2wb23ov7] FMOD_RESULT result;
GetSoftwareFormat( &SoftwareFormat );
//----------------------- // Create a sound to record to. FMOD_CREATESOUNDEXINFO exinfo; memset(&exinfo, 0, sizeof(FMOD_CREATESOUNDEXINFO)); exinfo.cbsize = sizeof(FMOD_CREATESOUNDEXINFO); exinfo.numchannels = 1; exinfo.format = FMOD_SOUND_FORMAT_PCM16; exinfo.defaultfrequency = SoftwareFormat._iSampleRate; exinfo.length = exinfo.defaultfrequency * sizeof(short) * exinfo.numchannels * 5; result = _pFmodSystem->createSound ( 0, FMOD_2D | FMOD_SOFTWARE | FMOD_LOOP_NORMAL | FMOD_OPENUSER, &exinfo, &_pSoundForSpectrumAnalysis ); ERRCHECK(result); //----------------------- // start recording // in the PC sample, a driver is selected. in the iOS sample, it's just 0. _iRecordDriverForSpectrumAnalysis = 0; result = _pFmodSystem->recordStart( _iRecordDriverForSpectrumAnalysis, _pSoundForSpectrumAnalysis, true ); ERRCHECK(result);
On the RecordStart, I get this crash in the logs
D/Omap4ALSA( 1306): open called for devices 00040000 in mode 0 channels 00000010…
E/Omap4ALSA( 1306): Failed to initialize ALSA CAPTURE device ‘plughw:0,1’: Unknown error: -22
E/AudioRecord(20605): Could not get audio input for record source 1
E/libOpenSLES(20605): android_audioRecorder_realize(0x349320) error creating AudioRecord object
Now this is 100% reproduceable on my Kindle Fire 1st gen, which is an older device.
It’s worth pointing out that
is present in the manifest.
For more information, I used the Fmod function getRecordNumDrivers to get the number of available drivers. The result it 1, so passing 0 as the driver handle is appropriate.
Just for kicks, I also printed out all the caps and info for that driver. It’s named "Android Audio Input" – it’s min and max frequencies are 16000. The sound format is PCM16.
The sound pointer that is passed to this is valid, and I’ve tried setting the sound values to a frequency of 16000 (it was set to 41000), I’ve tried making the sound stereo as well as mono, and I get the same crash regardless.
I don’t know if this a specific rev of android – I know the Kindle Fire 1 is based on 2.2 – since i don’t have enough devices to test on, suffice to say the client is seeing an approximate 50% fail rate.
Also, I can’t figure out how to get FMOD debug spew in the log? I’ve tried setting
[code:2wb23ov7]FMOD::Debug_SetLevel(FMOD_DEBUG_DISPLAY_ALL | FMOD_DEBUG_LEVEL_ALL);
result = FMOD::System_Create(&_pFmodSystem); [/code:2wb23ov7]
at the point where the Sound System is initialized but I’m still seeing nothing in the output log?
At this point, I’m entirely unsure what else to do. Help?
- JakeSimpson asked 6 years ago
- You must login to post comments
Firstly can you provide TTY output from the logging version of FMOD? You need to link with fmodexL, and update the Java static code to load the fmodexL library, once that is done the Debug_SetLevel calls will work.
Next, can you try recording at 8KHz? FMOD will try whatever rate you specify, if that doesn’t work it will try the default rate of 16KHz (which is supposed to be supported on all Androids).
Also you mention FMOD crashes, is this just the example code calling exit(-1) or does it in fact crash inside an FMOD function?
- You must login to post comments
Please login first to submit.