title: Can not restart an interrupted audio input queue in background mode on iOS
body: <p>I'm writing an iOS App using an AudioQueue for recording. I create an input queue configured to get linear PCM, stated this queue and everything works as expected.</p>
  
  <p>To manage interruptions, I implemented the delegate methods of AVAudioSession to catch the begin and the end of an interruption. The method endInterruption looks like the following:</p>
  
  <pre><code>- (void)endInterruptionWithFlags:(NSUInteger)flags;
  {
      if (flags == AVAudioSessionInterruptionFlags_ShouldResume &amp;&amp; audioQueue != 0) {
  
          NSLog(@"Current audio session - category: '%@' mode: '%@'",
                [[AVAudioSession sharedInstance] category],
                [[AVAudioSession sharedInstance] mode]);
  
          NSError *error = nil;
          OSStatus errorStatus;
          if ((errorStatus = AudioSessionSetActive(true)) != noErr) {
              error = [self errorForAudioSessionServiceWithOSStatus:errorStatus];
              NSLog(@"Could not reactivate the audio session: %@",
                    [error localizedDescription]);
          } else {
              if ((errorStatus = AudioQueueStart(audioQueue, NULL)) != noErr) {
                  error = [self errorForAudioQueueServiceWithOSStatus:errorStatus];
                  NSLog(@"Could not restart the audio queue: %@",
                        [error localizedDescription]);
              }
          }
      }
      // ...
  }
  </code></pre>
  
  <p>If the app gets interrupted while it is in foreground, everything works correct. The problem appears, if the interruption happens in the background. Activating the audio session result in the error <strong>!cat</strong>:</p>
  
  <blockquote>
    <p>The specified audio session category cannot be used for the attempted audio operation. For example, you attempted to play or record audio with the audio session category set to kAudioSessionCategory_AudioProcessing.</p>
  </blockquote>
  
  <p>Starting the queue without activating the session results in the error code: <strong>-12985</strong></p>
  
  <p>At that point the category is set to <strong>AVAudioSessionCategoryPlayAndRecord</strong> and the mode is <strong>AVAudioSessionModeDefault</strong>.</p>
  
  <p>I couldn't find any documentation for this error message, nor if it is possible to restart an input audio queue in the background.</p>