Audio Queue Queue Error

I am developing a project that has both streaming audio and playing sound from a file. I use AudioStreamer for streaming audio and I use avaudioplayer to play from a file. Both streaming and playback work fine until the application is interrupted by a phone call or SMS. But when call / sms arrives after rejecting the call, when I try to restart the streaming, I get the error "Audio Queue Error". This only happens when I used avaudioplayer at least once and after that I used streaming. When an obeject avaudioplayer is not created, in this case there is no problem resuming streaming after rejecting the call. I guess something is wrong with the audio course.

Help is much appreciated.

Update:

The code I'm using is below

void interruptionListenerCallback (void *inUserData, UInt32 interruptionState) { // This callback, being outside the implementation block, needs a reference //to the AudioPlayer object AudioStreamer *player = (AudioStreamer *)[streamerArray objectAtIndex:0]; if (interruptionState == kAudioSessionBeginInterruption) { NSLog(@"kAudioSessionBeginInterruption 1"); [player pause]; interruptedOnPlayback = YES; } else if (interruptionState == kAudioSessionEndInterruption) { NSLog(@"kAudioSessionEndInterruption 2"); AudioSessionSetActive( true ); [player start]; interruptedOnPlayback = NO; } } 

as you can see that I am using AudioSessionSetActive (true), it works fine until the avaudioplayer object is created. The problem only occurs when I use the streamer after creating the Avaudioplayer object, and if the application is interrupted by a phone call
or sms, I get an error. Audio Queue Queue Error ?!

+3
iphone
source share
2 answers

I had the same problem, in more detail the error message was "hwiu" (used equipment) or 1752656245. But I used MPMoviePlayerController before running audioStreamer. I needed to stop MPMoviePlayerController ([stop MoviePlayer]) before freeing it in the moviePlayBackDidFinish method. a stop should release some hardware components.

I hope this helps

+2
source share

You need to make the audio activity session active after interruption.

I don't know AVAudioPlayer, but if you use the audio queue services directly, you might have something like this as an interrupt handler:

 void interruptionListener(void * inClientData, UInt32 inInterruptionState) { if (inInterruptionState == kAudioSessionEndInterruption) { OSStatus rc = AudioSessionSetActive(true); if (rc) { NSLog(@"AudioSessionSetActive(true) returned %d", rc); } } } 

and pass this into your call to AudioSessionInitialize ().

You can also restart the session lazily:

 -(void)startPlaying { OSStatus rc = AudioQueueStart(queue, NULL); if (rc) { NSLog(@"startPlaying AudioQueueStart returned %d.", rc); if (rc == kAudioSessionNotActiveError) { rc = AudioSessionSetActive(true); if (rc) { NSLog(@"startPlaying - AudioSessionSetActive(true) returned %.d", rc); } else { NSLog(@"startPlaying - restarted Audio Session"); } } } } 
0
source share

All Articles