I am developing an audio streamer and have declared an interruption listener to save state of a song when an interruption occurs – like an incoming call or an sms.
Here is the relevant code
In my AppDelegate, I have this
AudioSessionInitialize (NULL, NULL, interruptionListenerCallback, self); AudioSessionSetActive(YES);
This is what the interruption listener looks like
void interruptionListenerCallback (void *inUserData, UInt32 interruptionState) { // This callback, being outside the implementation block, needs a reference //to the AudioPlayer object MyPlayer *player = (MyPlayer *)inUserData; if (interruptionState == kAudioSessionBeginInterruption) { if ([player audioStreamer]) { // if currently playing, pause [player pausePlayback]; player.interruptedOnPlayback = YES; } } else if ((interruptionState == kAudioSessionEndInterruption) && player.interruptedOnPlayback) { // if the interruption was removed, and the app had been playing, resume playback [player resumePlayback]; player.interruptedOnPlayback = NO; }
}
When I get a phone call the interruption listener is called and if the user declines the call the playback resume method is also called. But before the resumePlayback method is called, I get this error in the console for AudioQueueEnqueueBuffer
error: tca! error int: 560030580
Does anyone have an idea of how to correctly handle audio interruptions when streaming audio files.
Thanks.
This link shows what the problem is. Might help someone.
https://devforums.apple.com/message/31758#31758