I'm experiencing a nasty problem on iOS device related to audio playback. Tried to get some help from apple developer forum but does not seem like it is anyhow developer friendly. Hope I can get some help here.
The problem is that if during application load user presses "Home" button and minimizes the application the OpenAL does not get initialized properly and no sound comes out off my application anymore. It has to get totally killed and relaunched to get the audio working.
The error I'm getting right after activating OpenAL context is:
<0x3edabd98> AURemoteIO::Initialize failed: -12985 (enable 2, outf< 2 ch, 44100 Hz, Int8.24, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
<0x3edabd98> AURemoteIO::Initialize failed: -12985 (enable 2, outf< 2 ch, 44100 Hz, Int8.24, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)
Further I tried to hook up to audio interruption event in order to properly handle audio interrupts, but this does not seem to work. The interrupt handler is not getting called. I initialize the audio session like this:
AudioSessionInitialize(NULL, NULL, OpenALInterruptionListener, this);
and then try to handle the interruption like that:
void OpenALInterruptionListener(void * inClientData, UInt32 inInterruptionState)
{
OpenALDevice * device = (OpenALDevice *) inClientData;
if (inInterruptionState == kAudioSessionBeginInterruption)
{
alcSuspendContext(_context);
alcMakeContextCurrent(_context);
AudioSessionSetActive(false);
}
else if (inInterruptionState == kAudioSessionEndInterruption)
{
UInt32 sessionCategory = kAudioSessionCategory_AmbientSound;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
AudioSessionSetActive(true);
alcMakeContextCurrent(_context);
alcProcessContext(_context);
}
}
but anyway my "OpenALInterruptionListener" function is not getting called.
Any help is appreciated!
Thank you,
Ruben