• Advertisement
Sign in to follow this  

OpenAL interruption issue on iOS device

This topic is 2063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everybody,

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

Share this post


Link to post
Share on other sites
Advertisement
I had problems on some devices if I called AudioSessionInitialize after initialisation of OpenGL.
Also, the suspend should be like this:

AudioSessionSetActive(NO);
suspendContext = alcGetCurrentContext();
alcMakeContextCurrent(NULL);
alcSuspendContext(suspendContext);

AudioSessionSetProperty should be called at app initialization, not in OpenALInterruptionListener

Also, don't forget to check OpenAL return codes for an error. Edited by Ed Welch

Share this post


Link to post
Share on other sites
thank you Ed for pointing this out! will move the propertySet at the initialization.
All the OpenAL error codes are checked. I basically used a macro to catch and report errors after every OpenAL call.

Share this post


Link to post
Share on other sites

I had problems on some devices if I called AudioSessionInitialize after initialisation of OpenGL.
Also, the suspend should be like this:

AudioSessionSetActive(NO);
suspendContext = alcGetCurrentContext();
alcMakeContextCurrent(NULL);
alcSuspendContext(suspendContext);

AudioSessionSetProperty should be called at app initialization, not in OpenALInterruptionListener

Also, don't forget to check OpenAL return codes for an error.


Ed, something is still not right in my case. I followed your suggestion and moved AudioSessionSetProperty to app initialization but still my InterruptionListener is not getting called.
If that would make differences my engine is written in C++ and all calls to OpenAL are made from C++.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement