I’m running iOS 4.1 on a G2 iPod Touch, FMOD 4.32.08. I’m getting a crash on any code that attempts to do recording.

If I upgrade the device to iOS 4.2.1, it works just fine. Downgrade to 4.1, and I crash again.

Any suggestions? Here’s the console output from running the pitchdetection sample:

FMOD: SystemI::init : FMOD Ex Version: 00043208
FMOD: SystemI::init : maxchannels = 32, flags = 00000020, extradriverdata = 0x0
FMOD: SystemI::close :
FMOD: SystemI::close : Stop all sounds
FMOD: SystemI::close : Remove miscllaneous DSP stuff.
FMOD: SystemI::close : done.

FMOD: OutputCoreAudio::init : Initializing…
FMOD: OutputCoreAudio::prepareAudioSession : Setting override to force output through main speaker while recording.
FMOD: OutputCoreAudio::prepareAudioSession : Setting override to force mixing when usually not permitted.
FMOD: OutputCoreAudio::init : Maximum hardware read size: 4096 samples, Software buffer size: 1024 samples, Number of software buffers: 4.
FMOD: OutputCoreAudio::init : Hardware buffer size: 1024 samples, hardware sample rate: 48000Hz.
FMOD: OutputCoreAudio::init : Done.
FMOD: SystemI::init : Set up software engine
FMOD: Thread::initThread : Initializing FMOD mixer thread. priority 1
FMOD: Thread::initThread : – Stacksize 32768. Stack pointer 0x0 : usesemaphore = 1 : sleeptime = 0
FMOD: Thread::callback : * FMOD mixer thread started
FMOD: Thread::initThread : done.
FMOD: SystemI::init : Set up emulated output
FMOD: SystemI::init : create the channel pool
FMOD: SystemI::init : Set up streamer
FMOD: Thread::initThread : Initializing FMOD stream thread. priority 2
FMOD: Thread::initThread : – Stacksize 49152. Stack pointer 0x0 : usesemaphore = 0 : sleeptime = 10
FMOD: Thread::callback : * FMOD stream thread started
FMOD: Thread::initThread : done.
FMOD: Profile::init : Profiler listening on port: 9264
FMOD: SystemI::init : done

FMOD: SystemI::createSoundInternal : filename = : mode 0000044a
FMOD: SystemI::createSoundInternal : exinfo->cbsize = 124
FMOD: SystemI::createSoundInternal : exinfo->length = 480000
FMOD: SystemI::createSoundInternal : exinfo->numchannels = 1
FMOD: SystemI::createSoundInternal : exinfo->defaultfrequency = 48000
FMOD: SystemI::createSoundInternal : exinfo->format = 2
FMOD: SystemI::createSoundInternal : 17 codecs found. Scan all until one succeeds
FMOD: CodecUser::openInternal : attempting to open user codec..
FMOD: CodecUser::openInternal : Done. format = 2, channels 1, frequency 48000, lengthpcm 240000, blockalign 2.
FMOD: SystemI::createSoundInternal : Format has 0 subsounds.
FMOD: SystemI::createSoundInternal : Create as FMOD_CREATESAMPLE
FMOD: SystemI::createSoundInternal : creating subsound 0/0
FMOD: SystemI::createSample : mode 0000044a length 240000 samples, lengthbytes 0
FMOD: SystemI::createSample : subsamples = 1, channels = 1
FMOD: SystemI::createSample : subsample 0. output = 0x23fd30
FMOD: SystemI::createSample : mSoftware = 0x23fd30
FMOD: OutputSoftware::createSample : lengthpcm 240000, lengthbytes 0, channels 1, format 2, mode 0000044a
FMOD: OutputSoftware::createSample : done
FMOD: SystemI::createSample : done
FMOD: SystemI::createSoundInternal : No name found in file, use filename.
FMOD: SystemI::createSoundInternal : done. OpenState now = FMOD_OPENSTATE_READY.

FMOD: Thread::callback : * FMOD mixer thread finished
FMOD: Thread::close : FMOD mixer thread thread destroyed
FMOD: OutputCoreAudio::setupAudioSession : Cannot activate audio session. (err: 1852794999)
FMOD error! (62) Error initializing output device.

  • You must to post comments

Thanks mathew,

you are correct about the "crash" – it was only happening on iOS 4.1 as I had mentioned in my original post; iOS 4.2.1 just gives the error.

  • You must to post comments

Thanks for the details, I have been testing with our iPod touch running an old 3.x version and all was well. But after upgrading to 4.x I can see things have changed, I’ll have this fixed for our next release. It should return NEEDS HARDWARE from recordStart in that case.

BTW that’s not an application crash as far as I can see, the app closes because of the "exit(-1)" in ERRCHECK after it prints the error message.

  • You must to post comments

Thanks for the response. I’m able to avoid the issue by testing for AudioInputAvailable before trying to record, but the app actually does crash – that’s the end of the console output before the app closes:

"FMOD: OutputCoreAudio::setupAudioSession : Cannot activate audio session. (err: 1852794999)
FMOD error! (62) Error initializing output device.
Program ended with exit code: 255"

I just verified it on an iPod Touch G2 with iOS 4.2.1, again with the stock pitchdetection sample, no microphone attached.

  • You must to post comments

Ideally you should avoid using any Apple audio calls, that being said some are safe (generally the ‘get’ functions) however it is essential that System::init is called first (FMOD must call AudioSessionInitialize internally for things to work properly).

You should receive an FMOD_ERR_NEEDSHARDWARE error when trying to recording on a device that doesn’t have a microphone, there shouldn’t be a crash. Looking at the log output provided it looks like you were receiving an error, not a crash. You could either check for an error from recordStart (the FMOD way) or use AudioInputAvailable (which is safe, we use it internally too) as long as it’s after System::init.

  • You must to post comments

I’ve noticed that I will also get the same error if running under 4.2.1 without a microphone plugged in.

The recommendation here on the forums in general seems to be "don’t mix the AudioSession APIs with FMOD", but it seems I’ll have to at least do an AudioSessionGetProperty(kAudioSessionProperty_AudioInputAvailable…) to avoid the crash I’m experiencing. So, I have some questions around mixing the APIs:

1) Should I do System::init in my app before any AudioSession calls?
2) Apple guidelines are to call AudioSessionInitialize before other APIs. I assume FMOD is doing this internally, so if do System::init, can I skip this?

Thanks in advance.

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.