views:

508

answers:

3

I'm having difficulties starting the AudioQueue when my app is in the background with iOS4.0 The code works fine when the app is active, but fails with -12985 code when running in the background.

        err = AudioQueueStart( queueObject, NULL );


        if( err )
        {
            NSLog(@"AudioQueueStart failed with %d", err);
                = NO;
AudioQueueStop(queueObject, YES);
            return;
        }

For the code above, err is set to -12985

A: 

I've since learned that re-using an audioqueue from the background works just fine. You just can't start new.

dquail
A: 

I'm having the same issue. But even when I AudioQueuePause in background and then AudioQueueStart with the same AudioQueue, I get the -12985 error.

leighmcc
Ya. I think that you simply can't AudioQueueStart from the background. So I'm refactoring to just continually feed the buffer on demand instead of starting for each song I'm attempting to play. Essentially a shared queue that I never "AudioQueueStart"
dquail
The problem I'm having is with interruptions. So if their is an interruption to my audio session, I stop the Queue, then I start it when the interruption finishes but I get the -12985 error. I can't leave it playing in the background I don't think.
leighmcc
A: 

Making sure that my AudioSession was active fixed the problem: Previously in code I had set the session to inactive between song changes before starting a new song:

AudioSessionSetActive(false);

Once I removed this AudioQueueStart works just fine from the background.

dquail