title: Why call to CFRunLoopRunInMode() in Audio Queue Playback code?
body: <p>I'm following the iOS "Audio Queue Programming Guide - Playing Audio". Near the end of the guide, there are calls to <code>CFRunLoopRunInMode()</code> in the step <a href="http://developer.apple.com/library/ios/#documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/AQPlayback/PlayingAudio.html%23//apple_ref/doc/uid/TP40005343-CH3-SW40" rel="noreferrer">Start and Run an Audio Queue</a>:</p>
  
  <pre><code>do {                                               // 5
      CFRunLoopRunInMode (                           // 6
          kCFRunLoopDefaultMode,                     // 7
          0.25,                                      // 8
          false                                      // 9
      );
  } while (aqData.mIsRunning);
  //...
  </code></pre>
  
  <p>The documentation about line 6 says:
  "The CFRunLoopRunInMode function runs the run loop that contains the audio queue’s thread."
  But isn't that run loop executed anyways when my method returns? The code above is executed by the main thread upon pressing the play button in my app.</p>
  
  <p>Now I'm having a hard time understanding what these calls to <code>CFRunLoopRunInMode()</code> are good for, because they have the disadvantage that my play-button does not update correctly (it looks pressed down for the whole time that the audio plays) and there is no positive effect, i.e. the audio also plays nicely if I remove the do-while-loop from my code along with the calls to <code>CFRunLoopRunInMode()</code> and instead directly return from this method.
  Well this points to the obvious solution to simply keep these calls removed as this doesn't create a problem. Can someone explain why then this code is included in the official guide by Apple on using Audio Queues in iOS for Audio Playback?</p>
  
  <p>Edit:</p>
  
  <p>I'm just seeing that in Mac OS X, there exists the same audio queues API as on iOS, and the guide for iOS seems to be a copy-paste duplication of the <a href="https://developer.apple.com/library/mac/#documentation/MusicAudio/Conceptual/AudioQueueProgrammingGuide/AQPlayback/PlayingAudio.html#//apple_ref/doc/uid/TP40005343-CH3-DontLinkElementID_12" rel="noreferrer">Mac OS guide</a>. This leads me to the suspicion that those calls to the run loop are only required in Mac OS and not anymore in iOS, e.g. because otherwise the Mac OS application would exit or something like that. Can someone please verify this or rule it out?</p>