title: Receiving kAUGraphErr_CannotDoInCurrentContext when calling AUGraphStart for playback
body: <p>I'm working with <code>AUGraph</code> and Audio Units API to playback and record audio in my iOS app. Now I have a rare issue when an <code>AUGraph</code> is unable to start with the following error:</p>
  
  <blockquote>
    <p>result = kAUGraphErr_CannotDoInCurrentContext (-10863)</p>
  </blockquote>
  
  <p>The error occurred unpredictably when we try to call <code>AUGraphStart</code> which is set up for audio playback:</p>
  
  <pre><code>(BOOL)startRendering
  {
      if (playing) {
          return YES;
      }
  
      playing = YES;
  
      if (NO == [self setupAudioForGraph:&amp;au_play_graph playout:YES]) {
          print_error("Failed to create play AUGraph",0);
          playing = NO;
          return NO;
      }
  
      //result = kAUGraphErr_CannotDoInCurrentContext (-10863)
      OSStatus result = AUGraphStart(au_play_graph);
      if (noErr != result) {
          print_error("AUGraphStart", result);
          playing = NO;
      }
  
      return playing;
  }
  </code></pre>
  
  <p>Here what we get from the documentation:</p>
  
  <blockquote>
    <p>To avoid spinning or waiting in the render thread (a bad idea!), many
    of the calls to AUGraph can return:
    kAUGraphErr_CannotDoInCurrentContext. This result is only generated
    when you call an AUGraph API from its render callback. <strong>It means that
    the lock that it required was held at that time, by another thread</strong>. If
    you see this result code, you can generally attempt the action again -
    typically the NEXT render cycle (so in the meantime the lock can be
    cleared), or you can delegate that call to another thread in your app.
    You should not spin or put-to-sleep the render thread.</p>
    
    <p>This result code is only a transitory state, which will pass as soon
    as your other thread's call to AUGraph (that has the lock) completes.</p>
  </blockquote>
  
  <p>In my case, I just start the <code>AUGraph</code>, it's new and just created.
  How can I debug the case and what could be the potential issue here?</p>