Jump to content

  • Log In with Google      Sign In   
  • Create Account


OpenAL interruption issue on iOS device


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 rubenhak   Members   -  Reputation: 154

Like
0Likes
Like

Posted 17 May 2012 - 04:24 PM

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

Sponsor:

#2 Ed Welch   Members   -  Reputation: 463

Like
0Likes
Like

Posted 25 May 2012 - 06:25 AM

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, 25 May 2012 - 06:38 AM.


#3 rubenhak   Members   -  Reputation: 154

Like
0Likes
Like

Posted 25 May 2012 - 07:26 PM

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.

#4 rubenhak   Members   -  Reputation: 154

Like
0Likes
Like

Posted 30 May 2012 - 11:54 PM

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++.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS